Vitamin D is commonly low because you aren't supplementing enough in either getting your level up, then maintaining it or both.
You can safely take a daily dose of D3 supplement at 10,000 IU per day for 3-4 months if you have no known heart, kidney and liver problems.
A few endocrinologists think this is dangerous while in some areas to save money haemotologists recommend a level that is not enough for some people, and therefore some NHS areas set low levels.
Unfortunately this means you need to do your own research, pay for your own tests every 3 months until you level is high enough, and then buy most of your own D3 supplements.
In your case for vitamin D if it is around 40 you should take 5,000IU supplements daily for 3 months get your level tested using a City Assays test and then see where you are. Take your vitamin D3 with a fatty meal and also magnesium and vitamin K2-MK7 supplements. You can buy the supplements you need on Amazon and doing this way is far better than going into a high street shop. You are aiming for a level over 75nmol/L but preferably 100nmol/L.
City Assays lab is a lab based in a NHS hospital in the Midlands. Their tests are around £30 and are finger prick tests.
There is information on vitamin D via the vitamin D council and grassroots health websites.
If you don't want bad bones in 20 years you really need to help yourself and not leave it to your useless doctors. Sorting out a vitamin D level isn't hard but many GPs are still damn ignorant about it.
Finally if you haven't been told you need to take vitamin D supplements for the rest of your life. You cannot just take a break from them without knowing why. This is why you should try and understand about it and not leave it to the doctors even if they were helpful.