They don't "do it" as such. There was likely at some point in time a random hoverfly offspring that somewhat resembled a hoverfly....Perhaps it had a splurge of that aposematic colouration (might not have been perfect at the time). Predators though mostly avoided it, rather not taking the chance to eat it as it "might" have a sting. That random mutation just got expressed through generations or rather honed & selected through natural selection. Read about it. Darwin is fascinating 😀. Ignore the other post from the random Entomologist. It's likely he gets more of an ego trip out of being right rather than educating.
Many flies mimic bees to gain protection from predators, but they do an even better job at fooling photographers who should do their homework before posting erroneous captions.
Merodon equestris Male and female mate :)