The prosecution has to prove, beyond a reasonable doubt, that the person entered a structure with the intent to commit a theft or any felony.
Cases can be proven many ways. Unless the person admitted they entered the structure to commit a crime, the prosecution may argue there was circumstantial evidence to prove the person had that intent before entering, as opposed to deciding to steal something after coming inside.
If the structure is an inhabited building, it is first degree burglary; all other burglaries are second degree. Under Penal Code 459, "structure" includes a house, room, apartment, shop, warehouse, store, mill, barn, stable, outhouse or other building, tent, marine vessel, houseboat, railroad car, locked or sealed cargo container, trailer coach, house car, inhabited camper, vehicle (when the doors are locked), aircraft, and mines.