Buy a Pass for extended travel.
https://www.amtrak.com/take-the-trains-across-america-with-usa-rail-pass
Pack a cooler for carry on and stock it with easy to eat foods to make some meals for yourself. The train food can get expensive after a while. Many have a microwave available you can use to heat up something you have brought with you. NO you cannot use the kitchen galley to cook your own stuff.
Living ON the train is like being in a moving Hotel you are paying for each room night. You can get off the train every so often and spend a day or two enjoying the local things and stay in a cheaper place for the night.
Depending where you are going and which train you need to change to there can be a short wait for next train or maybe a days wait for the new direction.
Seriously being on a train non stop for month or more? You are taking up space and pay for it daily. You can get a reduced rate when you get a travel pass or use a discount if it applies to you.
I assume you realize that trains go from A to B. At the end of line YOU GET OFF. What you do next is up to you. Be it see the sights or get on some other train to travel some more. You DO NOT stay in the same seat for a month or two.
You used the advantage of a moving bed to avoid a hotel charge. You DO NOT get the view at night anyway.
In places with more train service like the North East in the USA you can schedule your arrival in the morning. Do your thing at the stop and then board your next ravel adventure later in the day sleeping to the next place.
Maybe for part of your extended travel you use the Bus for places the trains do not go. Just like the Airlines they have a rewards program for a frequent user.
https://www.greyhound.com/en/help-and-info/road-rewards
If you can travel at times with a companion there is a possibility of lower fares for the two of you when travelling together.