If you are stuck, this is probably where. With the usual G, your whole hand has to travel to get to D.
Land the shape all at once
With your hand off the strings, form the D shape in the air. Then land it. Lift, form, land. Do it ten times with no strumming, slowly. It will feel silly and it works.
Then do the same with G.
Look where you are going
Your fingers land together, but one of them leads. Decide which and aim for it. For most people the easiest guide into D is the third finger, on the 3rd fret of the B string. Into G, try your second finger on the low E string. Watch that finger and let the others follow it.
Or keep one finger down
Try a different G: second finger on the 3rd fret of the low E string, first finger on the 2nd fret of the A string, third finger on the 3rd fret of the B string, fourth finger on the 3rd fret of the high E string. Going to D, your third finger stays exactly where it is. Strum D from the D string only.
The one-minute test
Set a timer for one minute. Change from G to D and back as many times as you can, strumming once on each chord. Every move counts as one change, so G to D to G is two. Only count the ones that ring. Write the number down.
Do it once a day. The number will go up, and on the days when it feels like you are getting nowhere, the number will tell you otherwise.
When you get to around 30 clean changes in a minute, that is one change every two beats at 60, which is fast enough for a lot of real songs.
A trick for Em to G
Try playing Em with your first and second fingers, instead of second and third. Now your first finger, on the 2nd fret of the A string, stays down when you go to G. It is one less thing to move.
Do the one-minute test now, before you close this page. That first number is what you will be beating tomorrow.