Well, Hello
Some Bacteria make there own food from the suns rays or sunlight , Some bacteria are scavengers, For example there is bacteria in your stomach breaking down your lunch ! So that how bacteria get food.
Hope I helped God bless you and have a Blessed day!!