Can I buy a district after landing there by taking the train?
Yes, the rules specifically tell you you can. Under the Where Did You Land section on (page 7)

A district you own:
Do nothing unless there is a railroad on it. If so, you can immediately move to any other district with a railroad on it and buy it or auction it (if it is unowned) or pay rent (if it belongs to another player).