You pay taxes on the funds used to maintain the property. So unless you're in a market with obscene growth rates, you still lose money even if you earned capital gains on the transaction.
I just put together a spreadsheet assuming 1% maintenance, 1% tax rate, and 3.5% mortgage rate on a 250k house. You still would need a 5% annual rate of return to make money. After 15 years you would have hit your $250k capital gains limit, but you'd only have $70k in profit after taxes, interest and maintenance. At 3%, you lose money until well after the house is paid off.
I believe with proper documentation remediation is tax deductible in that you can raise your cost basis when you sell.
Further, your mortgage interest up to $750K is also tax deductible, and you have to index the whole thing to inflation. Once you do all that the costs are either nominal or negative on a 3.5% 30 year fixed deducted from a Bay Area income. Until Donny took us for a ride property taxes were deductible too.