In case you mean "famine" as in the actual disaster as opposed to simple starvation, that, like other disaster events, is random and can be countered with granaries. Granaries will not fix starvation, however.
As for losing money, you've built too many structures. Most of them will not help you enough to offset their building and maintenance costs and the remainder become useful with larger empires that have sufficient tax bases.