well see the first diaagram fig 5.1.....this is the normal extension....u can only apply f=k.e to this diagram but since we hav no data for extension in this diagram we cnt do that....now we know change in g.p.e will be equal to gain in strain energy....so in fig 5 equate this value to .5kx*2 to find k...hope u got it..u cnt apply f=k.e to this diagram cos u urself moved it up and then relesaed it.....it cn by the way only be applied in most ordinary case....such as first fig