Get the microwave oven checked out and repaired.
It should never turn on with the door open if it is working properly, as there are two interlock door safety switches which are supposed to stop this from happening.
If your hand doesn't look burnt it may be OK as microwaves heat the body tissues the same way as it cooks food.
Looking online there seems to be no correlation between microwaves and them causing cancer. Microwaves are more dangerous to the eyes and other more sensitive areas of the body though.
At best everything is OK, at worst you may have some burns but the severity of the burn depends on the microwave power setting at the time and how long your hand was exposed to it.
What is the model number of the microwave oven?