Why the comets can cross the orbits of planets?
There are several reasons, the main ones are:


The orbit of some comets may appear to 'cross' a planetary orbit when viewing the solar system in 2-dimensions, but their orbit does not lie in the ecliptic plane (that the planet orbits follow).  An example is Comet Hale-Bopp:




Analogous to why Pluto won't hit Neptune despite their orbits appear to 'cross' in 2D representations.

Image source: http://spiff.rit.edu/classes/phys235/comets/comets.html


Some comets do have orbits on the ecliptic, particularly some short-period comets, such as Comet Encke:




Same image source as above

However, it is important to note that the chances for the comet and planet to be in enough of a vicinity to each other to result in the comet being 'captured' by the planet is low - so if the planet is not nearby, the comet can just keep on going on its normal orbit.

Though we have witnessed if a comet gets too close to a planet, when Comet Shoemaker-Levy 9 got caught in Jupiter's gravitational field, tidally fragmented and eventually collided in 1994.

in terms of whether a comet could be captured in orbit around a planet, this has been addressed as answers to the question "Can a comet orbit a planet?".