How to react when encountering students who have previously failed my course?
Since you are at a small liberal arts college, I think you should not underestimate how much your own actions contribute to the culture of the college community. The notion of "avoiding" students is not something that you or your college wants to be known for (I imagine)! I think it is always best happily greet students that you know, perhaps ask them how things are going, etc. On some level, this kind of pleasant behavior is a professional obligation.
I don't think you should act any differently towards students who have failed your course (vs. students who did not fail, or haven't taken a course from you, etc.). Be cordial, and if the student wants to avoid you, then let them.
I will add that, while it's possible the student is mad at you, they may also be some combination of embarrassed and mad at themselves for failing. If they are embarrassed, then you avoiding them might make them feel worse, and you engaging with them might help them to get over the embarrassment.
TL;DR: be consistent
Speaking from the other side of this: I once struggled severely with one math class in particular and ended up taking it 3 times. I failed the first two times (the first try was a dud - I was a terrible student; the second time I gave it a good try but found the subject very difficult) then the third time with my studiousness greatly improved and my understanding of the subject finally sinking in, I aced the class. Here's where it's most relevant to your question: I had the same teacher all three times.
As other answers noted, the students really ought to be upset with themselves. Even bad teachers - and I had some qualms about this teacher - are rarely the sole reason for failure, as if so many students were failing the school would or at least could be urged to intervene. A large part of my failure was my own habits and then my own difficulties with the subject. How did the teacher handle that, and how would I have preferred them to have handled it? Thankfully, both those questions get the same answer; that teacher did a great job in my opinion.
The teacher was respectful, fair, and aware. It was a relatively small class at a huge school, so ultimately a pretty large class (~60 students). She acknowledged knowing me with simple eye contact, smile, nod that sort of thing and knowing my name (which is unusual in such a big class) but she did not make me feel uncomfortably highlighted at all, she respected my space and left it up to me to stand out or hide. She continued holding me to the same standard as before the 2nd and 3rd time I took her class, not wavering to have higher or lower expectations, which I appreciate. Lastly, she didn't ignore or emphasize the situation, but she did acknowledge it where appropriate: as I came to her for help one-on-one she'd gently give advice on where she thinks I need to focus efforts on or just general study tips, encouraging me to come to more office hours and work with TAs if I'm struggling, but then she'd leave it at that. No dwelling on past failures, no extreme pushing to get me through (I mean, she did fail me twice...err, or rather I failed her course twice). Even as I started to succeed (I eventually aced the class!) she maintained the qualities I described above, albeit more encouraging and "keep up the good work" rather than "I recommend you _____________". Her consistency with me, and also between me and other students, was an important part of the respectful relationship we maintained through it all (even despite my grumpiness through some of it, especially in my bad-student days where I'd try to put the blame on her when it laid most solely with me in that first attempt).
I'm surprised at the premise of this question. You're assuming failure is bad.
As educators, there's a responsibility to teach a subject matter, but also an implied responsibility to teach a culture and skillset that prepares students for life. If you teach your students that failure is something to be embarrassed about to the extent that it makes you avoid simple interactions with people who are aware you failed, then you're missing the opportunity to teach them that failure is a learning opportunity. By avoiding students, you're playing into the negative stigma, which is the real way you're "failing" these students.
Some others above have suggested not avoiding the students, which I agree with, but I really feel you need to take this a step further and incorporate a "don't be afraid of failure" attitude into the class itself, versus just after the fact. Help students prepare themselves for failure. Even if they don't fail your class, they're going to fail something at some point in their lives, and you have an opportunity to prepare them for that.