Can you take Pre-med classes at a CC instead of a 4 year uni and still get into a good Med School?

USF has sufficient rigor if you want to go to med school. Attending UCB won’t give you any significant boost in med school admissions. (UCSF doesn’t preferentially admit UCB undergrads. In fact UCSF doesn’t even give in-state preference in admissions.) Plus as @artloversplus mentions, if your grades & GPA drop post-transfer --that will damage your med school prospects. A downward grade trend is almost always lethal for med school admission.

Transferring institutions between junior & senior years means you’ll need to delay your med school application until after graduation. Adcomms will want to see 2 years worth of grades from your new institution. Plus you’ll need time to develop relationships with your profs at your new school to get the LORs you’ll need to support a med school application.