They can, but only gradually. You see, trains don't have good traction on the rails like cars do on roads, it's steel on slippery steel. On a bad incline, one wrong move can cause an entire train to slide downhill out of control. Train can indeed go uphill.