The rules depend on what court you go to. In the first instance, both sides pay their own lawyers, but the court fees are paid by the loosing party (1). The fees are usually not very high, so that‘s not much of a barrier. On an appeal, the loosing party pays all fees, including the opponents lawyers (1).
Being in a union pays off in labor court: Unions usually offer sending their legal staff instead of a lawyer that you‘d need to personally retain. This substantially reduces the costs of a court case for the employee.
See https://www.klugo.de/ratgeber/arbeitsgericht-kosten
(1) or shared, on partial wins.