While you can build your rail lines however you want, we recommend following the "standards" below, especially if you are connecting your rail line to the main network.
If you're building a railway, try to follow these guidelines:
Basically, you want rails to be as straight as possible for as long as possible, and then perform turns or elevation changes all at once.