It's a combination of things. Freight rail was obligated to provide passenger service in the past, and in return they got several rights that government would normally have including the right to use eminent domain and the right to have private police with public law enforcement powers. They were also given land holdings that they could turn around and sell at their discretion. Their ability to obtain land has made them a lot of money over the years, but apparently railroad rights of way are extremely valuable, where they've made money from renting out for utility lines. But the federal law that established Amtrak relieved the participating freight railroads from their obligation to provide passenger service. The law also says that freight railroads must give preference in dispatch to passenger trains, but obviously it hasn't worked out that way since the freight railroads provide dispatch for most of the country.
(c) PREFERENCE OVER FREIGHT TRANSPORTATION.—Except in an emergency, intercity and commuter rail passenger transportation provided by or for Amtrak has preference over freight transportation in using a rail line, junction, or crossing unless the Board orders otherwise under this subsection. A rail carrier affected by this subsection may apply to the Board for relief. If the Board, after an opportunity for a hearing under section 553 of title 5, decides that preference for intercity and commuter rail passenger transportation materially will lessen the quality of freight transportation provided to shippers, the Board shall establish the rights of the carrier and Amtrak on reasonable terms.
Amtrak has gotten determinations from the DOT's Surface Transportation Board that the freight railroads have been in violation of their obligation to provide Amtrak with priority, but they've declined to fine the railroads.
Amtrak owns its own rails in the Northeast Corridor. Stations can be owned by cities, counties, ports, etc. Some stations are even still owned by the freight railroads. But the rails are owned by railroads, even within stations.