Buses typically use GPS which are quite accurate when not too many tall buildings are around but accuracy degrades in build-up areas such as CBDs.
Trains either also use GPS or their locations are picked up when they cross certain parts of the rail network. In the latter case, the locations themselves are very accurate but the locations are typically reported less frequently than when using GPS.
Timing is also a component as the vehicles' data connection to the agency's data centre might drip out. It also depends on the internet connection between you and our servers. You are able to view the last time the positions were updated by tapping on the bus icon on the map (only visible when the bus has real time information available). It shows the number of seconds elapsed since the last update.