There are some problems with your code.
Firstly, there's no need for the function. All it does is make sure the object doesn't exist before it creates it, and if it does, it won't create it, and you'll later be left confused why this is happening. If you use the FreeObject function I gave you, it will always create a cube with a free object number, and it means you don't have to increment 'a' every time you want to make a new object. The whole point of functions is that you can group bits of code together, so you're not taking advantage of that.
As for your problem, this is because if there is a constant collision between the two sprites, and you're holding down the mouse, you'll always be calling the 'makeobjectcube' function. The way to deal with this is to only make it for the first frame of having the mouse pressed. To do this, you create a boolean variable, 'clicked'. When the mouse is not being clicked, set it to 0. When you want to create a new cube, only create it when clicked is 0, and then set clicked to 1. Take 5 minutes to think about how this works, then figure out the code for it. This is key to good programming.
"everyone forgets a semi-colon sometimes." - Phaelax