Ya I think you are leaving out the concept of Deprecation Recapture.
In short, if I buy the rental property for $10. Deprecate it to $0 over 27.5 years. Then Sell it for $20. I then haft to pay taxes on the sale of the profitable asset.
###### Depreciation recapture is a tax provision that allows the IRS to collect taxes on any profitable sale of an asset that the taxpayer had used to previously offset taxable income ######
https://www.investopedia.com/terms/d/depreciationrecapture.a....