Speaking as someone who's had some training as a psychological counsellor, I don't think your reaction was as uncommon as you might fear it is. Suddenly hearing about tragedy striking those close to you is a shocking experience that can cause yourself to be flooded with emotions. In a state like that, it's hard to control how those emotions come out, and sometimes they come out in a way that's not socially appropriate (such as laughing). This happens to many different people, and it is normal. Some people don't even feel anything at all. This is also normal, and you also can't control it because you can't make yourself feel anything. This is what happened to myself: I felt nothing when I heard that my grandfather died, and it wasn't until the memorial service four months later that the emotions hit me like a load of bricks.
The same thing can happen with your thoughts: We don't have control over what thoughts pop into our head, and sometimes the first thought that comes into your head can be really inappropriate for the situation. But thoughts are just thoughts; no more and no less. Thoughts can't hurt you, and thoughts don't make things true. The fact that you had the thought does not mean something is wrong with you. The fact that the thought gave your raw emotions a release in a way that is socially inappropriate does not mean something is wrong with you. These were things you had no control over, and from what I gather from your posts, it seems to me like they are not consistent with who you are as a person because you immediately recognized that they were wrong. We call this "egodystonic". If these thoughts and responses were egosyntonic (consistent with who you believe yourself to be), there would be a problem (on the other hand, you wouldn't think there was a problem).
It's important to be aware of what's going on inside you, and how your emotions and thoughts work. But fixating on a thought, feeling guilty that you had a certain thought or a certain emotional response, or trying to control your thoughts can lead to bigger problems. There's no use in feeling guilty or angry at yourself over something you had no control over, and trying to control the uncontrollable is a waste of your mental energy. Instead, I encourage you to be mindful of your thoughts and emotions, examine them without judgment and with curiosity, then let them go.