I dont understand why the option to board train keep dissapearing and reappearing and it seems completely random that some units are able to and some arent able to. Or a unit can board a train this turn but it cant the next.

Part of my procedure to do my moves is to first redeploy the aircraft units to better spots as needed, hold down the period key to disembark all the embarked units on rails, and THEN move the rest of the units.

_____________________________

Apparently there are three levels of brain activity. Level 1 is the lowest level - the amount of concentration required to, say, delete emails or serve in congress. - Bruce Cameron

This may sound obvious, but also make sure to check if you already have some units on trains at their destination, that you forgot about. They will use rail capacity until unloaded.

I certainly forget about this all the time

Exactly. If a player has entrained units from a previous game turn, that is counted against the current game turn's rail capacity. And yes, I too forget about them. Once detrained, the rail capacity is immediately increased.