Breeders will also sort out the animals of lesser quality to go to wholesale, so any animal in a pet shop is much more likely to have been the leftovers after the best ones are sold directly to the end owner by the breeder. There's also some cherry picking of animals after they are wholesaled, by the distributor's employees, and by the shop's employees, so what hits the sales floor has been picked over perhaps a couple times.
This isn't the only pool that pet shop animals come from, of course -- they could be bred in house, or come from a breeder who simply wholesales everything -- but if there is any sorting done in the supply chain the highest quality ones do not go for wholesale.
Buying from the breeder is virtually always going to lead to best results, and buying the least expensive animal is often not the best bet unless the buyer knows exactly why the price is so low and this reason is not a worry (for example, overproduction of a low-value morph).