It’s called a “crime of opportunity”....and they happen all the time. This one just happened to big and famous.
Oswald was looking to make a name for himself and had already tried to assassinate a ‘celebrity’ (Walker...a right-winger) months before. I bet he about jumped for joy when he read about the parade route and saw his opportunity.
In his narcissistic mind, he probably saw it as Providence.
Yes, it was just luck.
Bad luck...
...but luck nonetheless.