The idea that about 5% of the total mass-energy budget of the universe is in the form of baryonic matter is well-determined by cosmological observations (including the relative amounts of hydrogen and helium formed in the Big Bang). It if turns out we've overestimated the amount of baryonic matter in stars by a factor of two, that just means that 95% of the baryons are in the hot intergalactic medium instead of 90%.
Dark matter on the other hand is matter we can’t detect currently, but we theorize is there from its gravitational effects.
There’s a lot of other data like galaxy rotation rates, CMB, gravitational lensing, etc that effect dark matter estimates. I’m not sure how much of the current estimate is based on larger observable universe structure, so it’s an interesting question.