I took some fairly long exposure images a while ago of a quite scenic view near me with a rapidly setting sun in the background – I think I was using a shutter speed of about 30s.
As it got later, the stars started to become visible & even at 30s (it may have been 1min, but no more) the movement of the stars cross the sky is enough that they don't stay pin-sharp.
The moon in your second pick is very over-exposed & while this is to be expected to get the stars looking bright enough – it suggests that you might get away with a shorter shutter speed.
I take it you were using a tripod? Was it a windy night? The wind nudging your camera can be enough to throw these kind of shots out. Also, if your tripod has a hook on the underside to hang a bag from, make use of it – it will help to stabilise the whole thing (just make sure it's not swinging about, down there…).