Free living, nitrogen fixing bacteria are free living and have a protein that allows them to fix nitrogen to allow faster growth than the bacteria that need to get their nitrogen through other processes. They are often anaerobic (or functionally anaerobic) and so flourish in areas that are oxygen poor (like soil and decomposing organic matter) and by fixing the nitrogen present they enable other organisms to live there (their nitrogen fixing allows fungus to become established in the decomposing organic matter - the bacteria themselves aren't doing the decomposition). https://en.wikipedia.org/wiki/Paenibacillus_polymyxa is one such species of nitrogen fixing bacteria that forms a biofilm on plant roots, fixes nitrogen, and produces a substance that makes the plant roots more resistant to other pathogens.