I got caught writing my student ID number after the end of the exam. Will I get in trouble?
You are definitely overthinking this: in the worst case, they wrote down on their report that you wrote something when the time was finished. This could result in you getting your mark slightly reduced to account for the additional time.
I insist that this is the worst case scenario: this is clearly not a case of cheating, in all the exams I attended there are always a few students forgetting to write their student number and adding it at the end, some mistakenly writing their names, etc.
It is actually very likely that what you interpreted as a special treatment for your paper was completely normal. In my experience papers are collected in no particular order.
Take this angry frown for what it probably is: just a warning that you should follow the instructions.
It may turn out fine. But we will find out, won't we.
However, I have been in very strict military schools where pencils down, literally meant that. And your behavior would certainly be disciplined.
For one thing, you could have waited until the instructor got there and then got permission to make the addition (or asked him to make it for you). The instructor can't tell what you wrote, late. Neither can your classmates. Also, I have seen less strict schools where people did not honor the instruction to stop work. Behavior like yours is likely to make other students feel they can continue work and make it difficult to administer exams.
I would certainly support the instructors if they make any sanction on you.
In addition, the title is likely inaccurate. You got caught "writing", not "writing your number" after the exam. (The instructor likely does not know exactly what/why you continued to write or if it was just limited to the number.)
I surely agree with your dad. Don't over react over the reaction of that one supervisor. If he/she had seen you directly and doubted on what you're doing, on that moment he/she would have called your attention or not let you leave the room, cause definitely they will act on that exact moment. So just calm down for now, and if ever what your overthinking really happens (that they will call you to the office), you have nothing to worry and just say the truth.