Its nothing your doing wrong on this. Im afraid its a fault with the appliance itself.
From what you describe the thermal cut out is tripping out. This is usually caused by the cooling fan not running so it overheats in there and the thermal cut out trips out so thats why it turns itself off. Then once its cooled down which can take 20-30 minutes the thermal cut out resets itself and allows you to use it again.
So im afraid it is a fault on the microwave its nothing your doing wrong.
Im sure Samsung only give 12 monthes warrenty on microwaves so may be worth giving them a bell just in case and see what they say as they may do something for you as sometimes they do.
Sorry its not good news but if you need anymore info just get back to me.