I did my undergrad dissertation on the film.
there are two theories as to why it's called trainspotting.
the first is the use of the word as slang for a heroin user waiting for the blood to flow into their veins (tracks) after the tourniquet is applied. and obviously they're spotting a train on their 'tracks', aka trainspotting.
the second is a line in the book mentions begbie's drunken father and how he hangs around at the old leith train station (where trains no longer run) and how he's so out of it, he must be trainspotting...
hope this helps.