So in short, all of your assumptions are absolutely right. To make it more clear, I will try to explain it in details
So here the layout handle used is
default. This means, the layout updation that is hold by this handle will apply for almost all pages.
You are referencing to
header block then. This block is defined in
page.xml. Referencing this block is very important. You should "refer" to a block only after it is defined somewhere before it get referenced in your update. So here, you can refer this block only when if your layout update file is get considered by magento after
page.xml file get processed. I assume you are doing it in the right way :-)
Now your update script is removing the block
topMenu. That simple line do lot of jobs and that is what you probably didn't get. Suppose before processing your layout update, there are 10 top menus are added via another layout update XML Files (It may be programmatically also). So when your layout update is processed by magento, all those menu will deleted.
In short, removing a block removes that block along with all of its child block and all properties. So this line simply removes the entire top menu part along with all changes that have applied to this block through all other processed layout XML Files (if any)
- Now it again add a new topmenu block and then set a template for that top menu. This means you have again created a "fresh" top menu block which does not contain any child blocks or menus by default.
In short, your layout update script tries to remove all topmenu items that are previously created via other layout XML Files that had been processed by Magento before this layout update file get processed. Then it defines a fresh top menu items that may use to add top menus later.
I think you are still not clear with my point. OK I will explain it with a real time situation.
Suppose you need 4 pizzas to deliver. These 4 pizzas are made up of different ingredients (some ingredients are same and some are different). After prepared them, you have found that one of the pizza is not good for deliver. SO you removed that pizza and created another pizza instead for that. Then you delvivered those 4 pizzas to your customer.
Here pizza stands for topMenu block. So you have 4 topmenu blocks. Ingredients stands for its child blocks. As in the pizza's case, those blocks will treat as separate entities by Magento. Then you have removed the unwanted block then replaced it with another one. This exactly like in the pizza case. Removed and added pizzas are different and the only existing similarity is, they are of same type. Still at the end there are 4 pizzas available. So we have a topmenu available. Did you get now ?