That is the field of developmental biology which deals with organizers. Cell organizers are processes, genes and signalling proteins cells use to communicate / send and receive information from their neighbors, so that their spacial distribution in the body regulates their development.
The cells also have gradients of signaling proteins inside the cytoplasm, and cell polarity, so the cells know which way round they are:
"A spatially distributed signalling cascade can create step-like activation profiles, which decay at successive distances from the cell surface, assigning digital positional information to different regions in the cell. Feedback and feedforward network motifs control activity patterns, allowing signalling networks to serve as cellular devices for spatial computations."
All metazoans use the same types of organizers to develop different patterns of cells, so starfish use the same genes as mice to organize their axes. They are early metazoan genes/ Precambrian. Here is an in depth answer to your question: www.ncbi.nlm.nih.gov/pmc/articles/PMC5307799/
The cells know where they are, because they are receiving multiple signalling proteins from further away in the animal. Here is a picture of Bicoid morphogen in fruitflies:
The signalling proteins are received from cells far away, and that signals to other cells to make different kinds of signalling proteins to organize the local neighbors.
Given the complexity of metazoan morphogenesis, there are very many organizers and we only know a few of them. The axis formation is related to the Nodal gene which uses some kind of axial/mid-line located organizers to control symmetry, there are documentd about LRO: left right organisers, in starfish its the same chemistry in a different geometry. The Nodal biochemistry: https://youtu.be/kO8k9aiQJsQ?t=189