I got a B in my math class as a freshman, now I feel like I am not as smart as all of the other 4.0 kids

Many colleges apply relatively little weight to freshman year GPA. For example, you mentioned UCs. UC GPA excludes freshmen year. Stanford also recalculates without freshman year. This doesn’t mean freshman year is ignored, but it is given less weight.

In any case, getting a single B among countless A/A+ grades is obviously not a good measure of how smart you are. It also does not mean highly selective colleges are out of reach. I’d suggest instead reviewing what went wrong and what you can do in the future to improve. For example, what types of questions did you get wrong on the exams? Why did you get those questions wrong, if you reviewed past exams/material? Do you not understand the material well? Would help from a friend/tutor/family be beneficial?

Many students face similar struggles with their first B grade. When I was a freshman at Stanford, they had psych counselors come to my dorm after the first quarter midterms because so many students were struggling with their first non-A grades. I only had a ~3.5 GPA in HS classes (had 4.0 GPA at university classes taken while in HS), so I was used to getting B’s and had no need for counselors.