Yes Rats can and do sometimes learn to avoid rat traps so it can be impossible to get the rat if you haven't gotten them trapped in the rat trap during the first try.
If you set a trap and the Rat doesn't get into the rat trap on the first try then that same rat will learn that the trap is dangerous and not go near it.