It is a very common misunderstanding in the use of Python tags: many people think they can use them for just anything because Python is a general language. But there is one handicap: execution timeframe.
Tags are evaluated every time the object tree itself is evaluated. Which is very, very often (even during seemingly simple operations, like moving the view). Why is that done? Because potentially any change in the scene may have an effect on something and require a change. If your Python tag for example determines an object’s color by the position of the camera… it needs to be executed at any movement of the camera.
That leads to two main tenets in using Python tags: 1. Do not make changes to the object tree (generally) that you don’t want to be executed repeatedly, and 2. Make it swift so the execution duration doesn’t go through the roof (return as early as possible, do not perform unnecessary calculation).
As the previous poster said, the proper place for a one-time execution Python script is a command (which is executed only “on click”). C4D actually offers many more possibilities to trigger or callback a user-defined function, which is why it’s pretty important to know where to link your functionality. Many of them may be accessible only for C++ plugins, but in your case you may want to look into the Python Generator object, which is actually meant to create user defined geometries.