Same thing if your train transit costs 440 yens at base rate but you decide to ride first class or even one of the special luxury trains at a thousand+ yens, you'll only get the base 440 yens from your company.
On profitability, as mentioned by sister comment, they all have a realtor arm and also rent the space surrounding the stations to shopping malls and department stores, sometimes own or revenue share with the attractions in the town that will bring more visitors and they'll talk with he city planners to foster a whole ecosystem, JR famously gets a cut from every Suica transaction etc.
They don't need to make it all from the ride ticket, even if it's price appropriately. Government has little to do with most of it, subsidies only matter on the smaller, super low volume lines where rising prices would kill the traffic.