Who are the Rishonim that hold that asking a Rov a shailo when someone has a sofek in the din is counted as one of the 613 mitzvahs?
I don’t know which rishonim you are referring to here.
The Gemara (Nida 20b; Avodah Zara 7) writes that once a rabbi rules on a question another rabbi cannot rule to the contrary, but no Torah verse is mentioned (some rishonim explain that the rationale is that the question has already been resolved, and others mention the cause as the honor of the first rabbi). See https://dinonline.org/2011/05/25/going-to-several-rabbis-for-one-question/ for more details.
The Chinuch maintains that the mitzvah of adhering to rabbinic instruction applies even in our days, whereas other rishonim dispute this and maintain that the mitzvah applies only in times of the beis din ha-gadol.
Somebody who has a halachic doubt has to reach a solution, and this is the reason to go to a rabbi. If a person is able to reach the halachic verdict on his own, there is no need for the rabbi.