How do I install baseboards behind bifold closet doors?
You don't. Either stop the baseboard at the corner and live with the gap, or frame the opening with baseboard or molding and overhang the edge.

Notice how in this picture you can't see the metal track at the top, and you also can't see the gap between the outer left/right edges of the doors and the wall. That's because the molding overhangs the wall by 1/4 to 1/2 inch.