Not a dumb question at all. It is one of the major issues of developmental biology: how cells differentiate. An undifferentiated stem cell is obviously receiving information — signals — from the outside that tells it what type of cell to turn into. But it is such a big topic that I can tell you little here in a comment. You can get the highlights in this fairly well-written Wiki article:
https://en.wikipedia.org/wiki/Cellular_differentiation
Thanks for the link. I’ll have to wade through it but it’s so fascinating and thought provoking.
If I could have a redo, I’d go into micro biology.