Following is a response from DHS staff member, Tom Pullum:
Either sequence of steps will work, but I agree with you that it would be more efficient to restrict the age range to 6-23 months in the first step. I will paste below the Stata lines to identify the reference child with "egen seq()". Some people add a step to require that b5=1, but that is not necessary because if b9=0 then b5 must be 1.
* Steps to find the youngest child age 6-23 months living with the mother
* Illustrate with Nepal 2022 survey, KR file
use "...NPKR82FL.DTA", clear
gen select=0
egen sequence=seq() if b19>=6 & b19<=23 & b9==0, by(v001 v002 v003 bidx)
replace select=1 if sequence==1