Usually it depends on what went wrong; more precisely, where it can receive attention for whatever it was that went wrong. Hopefully it has been declared a failure somewhere where it's out of the way, or if not somewhere it can safely be moved out of the way. That's unlikely to be critical if it's in a bay platform at Aberdeen for example, Network Rail would probably be accommodating to a request for it to stay there overnight if it couldn't be avoided, but it would be rather a problem if it were in a through platform at Dundee. If a train is stranded i.e. the public are stuck onboard and the train can't be moved because of the fault, dealing with that is likely to come first.
Once that priority has been addressed and everyone has assured themselves that it isn't a safety risk for the line, can whatever it is be fixed by a fitter in a platform? If it's actually a failure, probably not, but maybe. Much depends on if it's completely demobilised or just unfit to carry passengers. Can it still be worked in the normal manner from the other end only? Is there a wait for attention by a fitter? If the unit cannot carry the public, and the issue can't be effectively tackled while it's in a platform, but it is safe to move around empty as normal, when can a driver be sourced to move it? If it isn't fit to be driven at all, it may be that it needs to be rescued by a classmate (or a cousin) and dragged back home in ignimony.
As noted above by
@Segedunum it appears something like the former was probably at play with your unit, i.e. the place with the tools to fix it was Haymarket and it could still be moved there under its own steam, it just wasn't fit for public use.
A failure could be 1,000 things from an external cab door which is jammed in the open position to a total loss of power in all vehicles, and everything in between.