I'm not sure which bit you mean by 'the end of this episode'. The very end of the episode, unless I'm completely misremembering, was a cliffhanger where Bolton's men encountered Jaime and Brienne. I don't remember the book perfectly, but I know this encounter happens, although not with Bolton's men. In the book the fight between Jaime and Brienne isn't on a bridge, it's just in a wood or something, and the men who encounter them are able to find and sneak up on them because swordfights are loud. But no, in terms of coincidence, there's no justification for why they get found other than 'there are lots of different groups of soldiers patroling the land looking for Jaime, and they weren't being stealthy'.
Now, in the book, this is slightly different because there's a group of mercenaries - the Brave Companions - who have been written out of the show, and they're the ones who encounter Brienne and Jaime. There's a bit more tension there, because you don't actually know who the Brave Companions are working for, since they're mercenaries. They start off aligned to Tywin, and hold Harrenhall while Arya is there, but betray the Lannisters because they do a deal with Bolton - Arya uses Jaqen H'ghar's final assassination to try to overthrow the Lannisters in Harrenhall by freeing some captive Stark men, but it turns out that the Lannisters were simultaneously being betrayed by the Brave Companions and were going to lose Harrenhall anyway.