given that germany is the country where this custom is common, and adding that especially in germany any non-german can easily be recognized by their name alone, giving racism as the reason for that custom to develop is almost absurd.
you have to keep in mind that germany has a strong fear of history repeating itself and has strong laws to prevent that. so any hint of xenophobia in the hiring process could be a PR or legal nightmare for a company.
if photos on the resume would be a problem in that regard, they'd have been outlawed already.
if i were to speculate for the real reason then it is whether the applicant looks presentable. german office culture is rather uptight. it is also likely that it started on the candidate side, and that people realized that including a picture would make them stand out more.