Children know the core social markers that are ascribed based on genders from an incredibly young age - 3 or 4. That's when our son started declaring he didn't like pink because it was a girls colour (despite being raised in a family that places zero stock on gender stereotypes, being raised around all manner of toys and clothes).
Because that is the point that he learned that in this society, not liking pink was a way to communicate that he is a boy and not a girl.
He's not a boy because he told us he doesn't like pink. He told us he doesn't like pink because he's a boy, and that is one of the ways society has taught him to communicate that fact. That is a crucial distinction.
Similarly for a a child assigned male at birth who might not only prefer pink, but stridently insist on surrounding themselves with pink things and have a strong aversion to anything associated with boys. The logical link is not 'they like pink things ergo they are a girl', the logical link is 'they are very persistently and stridently linking themselves to things stereotypically feminine because that is the way society has taught them to communicate that they are a girl'. Even then, that in itself is not sufficient for a child to be trans (because there may well be other reasons for that strident preference or aversion. But when it gets to that level, it can be an indicator.