I don't think it matters how you establish context for your questions. The criticism in the comments is about the content you referred to, not that you referred to another SE answer rather than some primary source. I think you would have received the same feedback if you had cited the American Academy of Pediatrics directly rather than through an answer on Psychology SE.
If what you are citing is controversial then it helps to present the source in that light. The way you quoted the excerpt in your question seems okay to me, you restate what was posted on Psychology SE passing little value judgement. If you wanted to be more cautious, you could introduce the quote as follows:
This Psychology & Neuroscience answer provides a quick overview of how the American Academy of Pediatrics defines the difference between sex and gender:
That way, you provide no endorsement at all as to the correctness of 'the difference between sex and gender' as stated in that source. Even without your endorsing the source it can be useful to include in your question because it establishes the different viewpoints.
For more on that, consider this article entitled Cautious Language and Hedging by University College London. As you can see, striking the right tone when referencing information is a universal issue, it's certainly not unique to citing from other Stack Exchange posts.
So to answer your question, yes it is okay to use other SE posts to provide context for a new question.