It depends.
There is compost and there is "compost".
And some topsoil is better than others.
Most commercial grade "compost" is a mixture of
wood chips and cow
poop. While both of these are technically industrial waste, these two ingredients are relatively benign (downsides for woodchips: allelopathic effect (a sort of natural herbide), acidic, sucks nitrogen out of it's immediate environment (the opposite of what you want for a lawn). downsides for cow poop: usually from a really gross feed lot where the critters are heavily medicated - and that medicated stuff is still in the poop - sometimes including deworming stuff which can kill your earth worms)
To re-iterate: I think wood chips and cow poop are **relatively** benign.
Some "compost" includes the industrial wastes of really nasty stuff. For a company to dispose of their waste properly, they would have to pay big bucks. But if they put it into "compost", they can
sell it. The past couple of decades have exposed some really awful things down this road.
Nearly all commercial compost sold today contains clopyralid. A broadleaf herbicide with a half life of 11 years. It just lasts so long and it ends up in everything. It passes right through the cow. It ends up in the wood chips. It is in the grass that is mowed and sent to the
composting facility.
Home made compost, however, is 100 times better than anything you can buy. The problem is that the amount most folks generate is not much.
I could write lots more on this, but I need to rope it in and say ....
Topsoil is dirt (sand/clay) and organic matter. Lots of places make topsoil by mixing dirt with "compost". Sometimes it is actually the top six inches of soil from some field that is being stripped to put in houses. But be careful, that topsoil (or the dirt) can contain clopyralid or all sorts of other toxic problems.
I tend to try to build the soil rather than import stuff. If I do import stuff, I am very particular about the ingredients.