Strictly speaking, you are describing axial myopia, indeed caused by a change in the eyeball shape. In some cases, the cornea itself maybe the problem. But your question is still valid for axial myopia and I will try to answer.
Regarding the laser operation acting on the cornea, it is the same as wearing glasses or contact lenses: You adjust the (innocent) lens (the refracting and focusing machinery of the eye) to offset the disabling defect of the (guilty) eyeball. To put it in physics terms:
You have a lens (the refracting and focusing machinery of the eye, which includes the cornea) positioned perfectly in front of a screen (the retina), so that the focal point of the lens lies on the screen. Perfect vision.
Now for some reason the screen is shifted backwards or forwards. (That's the eyeball muscles misbehaving.) You want to shift the screen back to its original position, but you cannot (muscles won't obey, surgical procedure difficult,...) So you operate on the lens (the refractive machinery) and change its focal point so that it lies on the newly positioned screen.
More on the underlying mechanisms of myopia:
https://en.wikipedia.org/wiki/Near-sightedness#Mechanism