Mostly true, but it's confusing. Historically, sex and gender have been used interchangeably. That is slowly changing. There are a lot of places that refer to "sex" where "biological sex", as you put it, is not what is meant. See e.g. how trans people can still get their "sex" updated on documents that refer to sex and not gender, and how many places described as single-sex are actually closer to single-gender.