My intent was to remove the final finish and not to go down to bare wood.
As I say in the Comments, this confuses me because removing final finish is synonymous with going down to bare wood.
After reading some threads, I understand that sanding is the last resort. Whether this would apply to my situation I don't know
Yes, sanding should be the method of last resort to remove old finish. And yes, it applied to your situation since this applies universally.
There are numerous reasons for this, but it boils down to the high potential for damage to pieces. In addition to the unintentional rounding of sharp features one of the main risks is sanding through veneers. The more modern the furniture the more this applies, because veneers have become thinner and thinner through history as wood values increased and the technology improved1.
As much as possible chemical strippers should be relied upon to remove old finishes. It's a dirty, sometimes smelly and always messy job that tends to take longer than anyone wants it to2, but it's still the best way. If stripping is not an option (for any reason) I would rely on scraping, because it's much more efficient than sanding and far more controllable if done correctly.
I sanded the vanity top starting with 120 grit using a hard block behind the sandpaper. I gradually went up in grit to 400, hoping to smooth out the top.
Sanding with the paper backed by a hard block was good, sanding up to 400 grit was not.
400 grit is far finer than necessary on almost all furniture work, and specifically not what you want to do when staining because the finer you sand the less stain the wood takes. When using a clear protective finish as the final step in general you can stop sanding at 150 or 180 grit. You can even get away with using 120 as your final grit sometimes!
What will be the best way to remove the scratches?
You might not be able to.
The major scratch visible in the first two photos might be too deep to remove, and may require filling.
I have successfully removed cross-grain scratches that might have been approximately this severe on veneered surfaces, but it's hard to get a proper sense of scale on your scratch. It does look very bad but some of that impression is from how the bottom is catching the light and the dark stain caught on both 'walls' of the scratch.
Without anything to go on to asses the thickness of the veneer you're working with I'm not sure whether to advise further sanding (or scraping) to get it out.
If you don't want to risk it you either have to live with them, or do some kind of filler work. Filling is too complex a subject to get into here so further research will be needed on your part.
It might also be worth trying steaming the worst scratches, but only if you can get back to bare wood beforehand.
I used Varathane Premium wood stain. It colors in 1 coat
From what I can see on the Varathane site you used this (since their waterbased stain says "classic" on the flash on the label, not "premium"). FYI this is an oil-based stain, not their waterbased stain.
It doesn't actually matter which type you used (except for how exactly to proceed later3) but this would appear to account for the sheen seen in the photos you added.
If Varathane Ultimate Polyurethane Water Based is the waterbased finish you intend to use I wanted to highlight the recommendation to use a minimum of 4 coats. Note the use of the word minimum.
1 They have become very thin in the modern era, to the point where on many recent pieces you can't risk any amount of heavier sanding.
2 It's best to go into a project expecting that stripper will NOT remove all the finish in one go. Time-served pros were often trained to strip three times to be thorough (and to avoid the need for ANY heavy sanding, something considered absolutely vital when working on antiques).
3 You want to wait MUCH longer before final finishing if overcoating with a waterbased clear as you've indicated you intend to.