Here's the rule:
When in the scorer’s judgment a runner attempting to steal is safe because of a muffed throw, the official scorer shall not credit a stolen base. The official scorer shall credit an assist to the fielder who made the throw, charge an error to the fielder who muffed the throw and charge the runner with “caught stealing.”
On close plays where the fielder is trying to catch, tag, and avoid getting knocked over all at the same time, most scorers will award the stolen base even though an on-target throw is dropped.
It's not always fair, but the runner who initiates action and applies pressure to the defense usually gets the benefit of the scorer's judgment. Most scorers are reluctant to award a "caught stealing" on plays where the runner was not in fact caught unless the catcher clearly had the runner dead to rights with an early, on-target throw that was blatantly misplayed by the fielder.
(Most catchers' dads would also award errors a) to infielders who allow the runner to reach second safely because they can't resist the temptation to reach out for the ball instead of letting it travel all the way to the base, and b) to pitchers who fail to hold runners or deliver the ball quickly.)