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.