If you start late, just get military science and learn attack for the rest.
In the early age, housing and alchemy are worth more than they are later, and that is where I usually dump the first war win's science.
Most attackers do well by going for housing and military science, since they lead to the best direct bonuses to attacking power and help in attaining the other sciences faster. I like to have roughly even levels of both and alchemy, and about 1/3 of my housing investment in tools+food, at least up until YR4-5. Aside from that, it depends on race and personality picks. Also note that food science becomes less and less valuable at higher bpas, but it's still a valuable science for anyone. After the first month of the age is when you should assess where you are and who you are going to fight, and diversify your sciences according to your kingdom strategy.
Also note that early age you might want to crash invest in channeling or crime in order to help your first war, and even if you don't, you should still attain basic levels in all sciences. Generally I like to get up to 16-25 bpa in everything before prioritizing housing (or, use the first war win to get housing+alchemy and backfill the rest).
Also, if you plan to invest in crime/channeling, or are uncertain what you are going to do, you should not invest your books until they are needed, since crime/channeling aren't very useful oow.
By mid-age (YR6 or so), avian and dwarf attackers should look at even investment in everything, as should any Sages (at least in war kingdoms). Elves should be roughly even on everything as well, and rely on their racial and likely personality bonus to stay effective as casters. Orcs should be going mostly for housing+military and learn attack for crime/channeling they need, but they should have at least 1/5 as many crime/channeling books as they have housing+military. Undeads favor channeling science, which they can attain from not needing or wanting alchemy+food+crime. Halfers should just go straight for housing+crime in order to maximize their racial attributes, with that they can either have the mTPA needed to op other t/m or drop some rTPA for extra military.
It is better to look at ratios of science rather than bpa in each category, though bpa per category is a good marker to know when to shift your priorities. You generally don't need more than 256 bpa in housing for instance, and alchemy shouldn't go much past 100-120 bpa unless playing Merchant. Also helpful is investment at the right time... the best time to pick up housing+alchemy is just after a war win, while backfilling the others to your desired ratio.
By late age I like having crime if I'm Avian, balanced science if I'm Dwarf (and a higher priority to tools+food early on), military if I'm Orc, and channeling if I'm Undead. If playing Sage, you should aim for level science in everything from an early point, in order to get the most bonuses for the least investment, while Mystics and Rogues obviously benefit from crash investment in their specialties. If I'm Elf, I like to have level investment in everything early, even if I'm Mystic, so I can rely on my racial bonus, likely personality bonus, and priority to wpa pumping to be effective for the first month or so; having good bases is useful for not falling behind other attackers early, even if I play a pure t/m. Human favors housing and alchemy, but they're horrible if not playing a true cow. Halflings want housing and crime from a very early point, in order to be able to better op t/ms - using high crime mods alternatively allows for a reduction in rTPA in exchange for military, while still being able to op attackers.