I believe that your notion, kx=mg, is wrong.
But the second one is right.
Anyways, why did you equate the forces? The body is neither at rest nor in uniform velocity. At the extreme point, the particle might be momentarily at rest, but this doesn't imply that its acceleration is nullified.