Why do my pastries come out flat when I use butter instead of margarine?
How funny since I learned this same recipe when I first got married 40 years ago. Here are the secrets I've learned. Maybe the extra detail will help you find what went wrong with your attempts.

First, you need to have everything at room temperature, especially the eggs. Once you add the butter (yes, butter, not margarine!) to the boiling water that is boiling and it melts, add the cup of flour quickly to the water and with a big spoon mix it fast. It will form a ball. Get it off the heat.

Now, get a mixer and add each egg, one at a time, and mix it thoroughly after each one - but don't overdo it. Do it quickly.

Now with either a pastry bag or a spoon (I use a spoon), drop rounds of the mix on a cookie sheet with parchment paper. Use approximately a 1 1/2 to 2 inch spoonful, so you will have anywhere from 18 to 22. Do not play with these. 

Put in preheated oven of 400 degrees for about 30 minutes. The baking time will depend on size. When you take out of the oven, they look beautifully puffed, but if not baked properly, will start to deflate.  So depending on the size, your oven and your patience, you'll have to adjust, but with practice you will master this. It's okay to open the door at the 20 minute mark to turn the cookie sheet, and get a idea if you need to go 10 or even 15 to 20 more minutes depending on the softness of the puff. Even if they deflate, it's okay. 

Cool, cut then in half, fill them with a nice custard cream, top them off with the lid, either make a nice chocolate ganache or frosting or if you are lazy or tired, sprinkle with powdered sugar or cocoa powder.

You can also make whipping cream but once you make a good cream custard, no matter how badly deflated the puffs are, people don't usually notice with something on top. It's always been a hit and long ago I used to make only 12 and filled them up with my own special cream and they were the size of baseballs, topped with homemade frosting and I hope you try it.