Welcome to the forum.
The first thing to say is that you don’t need to be scared. The worst possible outcome would be a fine (plus additional costs) from the courts, which might also mean that you needed to mention this for a year (longer for some things) if a DBS check (Disclosure and Barring Service) was needed. But I can say certainly that you will not be sent to prison. So don’t be scared.
And it’s quite likely that this won’t end up in court, as long as you keep in touch with the railway. They may well offer you the chance to settle out of court, which will almost certainly be cheaper than a court fine, and could not show up for DBS. So the first question you need to ask yourself is whether the wrong address that you gave is one that you have access to - which would be something like your parents’ or a friend’s address. In this case, then you need to talk to whoever’s at that address to get them to pass anything from the railway to you - and if the railway write to you, then when you reply you need to let them know your real address,
If the wrong address you gave is one that you don’t have access to or made up, then things are a bit more difficult. You say that the inspector gave you a small piece of paper: have a close look at that, and hopefully it will have a reference of some sort on it, and contact details. What you now need to do is to use those contact details and the reference to get in touch, and let the railway know what your real address is. If there isn’t a reference, explain what train you were on, and also give the information that you gave by mistake.
It might be tempting to not get in touch with the railway - because how can they trace you if they haven’t got your address? But in that case, what happens is that the matter goes to court: you won’t hear about this (because the railway doesn’t have your proper address) and so you won’t be able to defend yourself in court - so in turn you will be found guilty and fined. And when (because you didn’t know about it) the fine isn’t paid, it will be passed to debt collectors. Debt collectors are paid by results, so they WILL find you - and when they do, as well as the fine and court fees, you will also have to pay the debt collector’s costs. In short, running away from the problem won’t work.