What's the difference between 浪费 and 白费？
The crux is in the 白.
浪费 is similar to squander.
Here’s a good example from Oxford:

浪费自然资源
squander natural resources

To understand 白 I think it’s best to look at 白白 check out A Chinese-English Dictionary’s definition:

in vain; to no purpose; for nothing

here are two sample sentences they give:

白白丢掉一次机会
báibái diūdiào yīcì jīhuì
let a chance slip through one’s fingers; miss an opportunity



不要让时光白白过去。
Bùyào ràng shíguāng báibái guòqu.
Don’t let time slip aimlessly by.

So here we’ve got words like slip, miss, aimlessly and that is really what 白费 is made up of: slip/miss and squander - giving us: to do something in vain, to do something to no avail.
Here are two more examples from AC-ED:

白费力气
báifèi lìqi
waste of energy; all for nothing; plough the sand



白费心思
báifèi xīnsi
bother one’s head for nothing