All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
This behavior is not tantamount to disbelief or mockery of Allah’s creation on your part.
However, it was not permissible for the said teacher to insult that student, nor for you to laugh at him. Therefore, you should ask Allah’s forgiveness for what you did.
After all, you should not be obsessed with these thoughts or pay attention to them. If you give in to these whispers, they will harm you and not benefit you and will lead you to a great evil.
Allah knows best.