A "vanity unit" is basically a table that can either be below a sink or just in a bedroom that contains drawers. It appears to have no obvious link with the standard definitions of the word "vanity". Why is such a table referred to as a "vanity unit"?
I think the meaning of vanity in “vanity table” is literal, probably influenced by the fashion trend of “the dressing table” and its evolution in the ‘20s and ‘30s when it became emblematic of the movie heroines of those times. From The History of the Dressing Table
It was not until the early part of the 20th century, during the Art Deco period in both Europe and America, that luxurious dressing tables came to epitomize the modern concept of glamour and luxury.
Hollywood films of the 1920s and ’30s, with their fantasy world of penthouses atop Manhattan skyscrapers, were hugely popular during this period and often depicted the femme fatale heroine sitting at her supremely elegant vanity table in the bedroom or dressing room. Norman Bel Geddes’ enamel and chrome-plated steel dressing table (1932) is a model for this streamlined and sophisticated style.
The expression, as suggested by Etymonline, is from 1936.
Vanity, suggesting an empty or worthless pride, was long connected to personal appearance, and the word eventually gained a transferred sense of the products that maintain said appearance and the space in which said appearance is maintained.
The Oxford English Dictionary, under "vanity, n." gives citations for "vanity unit" starting in 1973, and "vanity table" in 1936.
1936 L. C. Douglas White Banners i. 9 The mirror of the vanity table.
1973 A. Roos Dunfermline Affair 162 The limed-oak furniture was all built in. Wardrobe, vanity units, dressing-tables.
I was able to find a mention a couple of decades earlier in the Grand Rapids Press, April 7, 1916, page 14 (Readex):
These were shortened to vanity almost from the start, as these close-in-time examples attest:
1937 ‘E. Queen’ Door Between xiv. 148 She sat down before the vanity to cold-cream her face.
1967 Boston Sunday Herald 26 Mar. (advt.) Classic elegance for your bathroom is yours with this 30 × 20-in. vanity... Vitreous china top and bowl.
As a word, vanity has long been associated with personal appearance:
a1781 R. Watson Hist. Reign Philip III (1783) ii. 100 She cannot be vindicated from the imputation of female vanity, and the love of admiration on account of her exterior accomplishments.
This sense influenced the development, at the turn of the 20th century, of a vanity bag or vanity box that contained cosmetic products for women:
1907 Yesterday's Shopping (1969) 404/1 The Vanity Bag. Containing on one side mirror, separate pocket for powder..with puff,..gusset pockets..for gold on other side, pocket for cards, papers, &c.
1911 G. R. Chester in Sat. Evening Post (Philadelphia) 30 Sept. 4/1 She carried her own vanity box.
Other items associated with the place where such products were applied would follow - the table, the mirror, the unit, and of course the vanity itself. In the US, patents are registered for the vanity ensemble, console, and stand from 1933 (Designs 91,111, 91,112, and 91,113).