I'll start with the assumption that behaviors exhibited by animals are generally the result of a long evolutionary history, with a little improvisation and chance thrown in here and there. This means that behaviors exhibited by animals are ones that caused their ancestors to have more offspring and pass on the traits for exhibiting those behaviors to their offspring (thanks, Charles Darwin).
Clearly the mating behavior I observed in the cicadas is necessary for the production of offspring and passing on genes to the next generation. However, the fact that the cicadas were mating in the middle of a well-traveled concrete pathway would seem to be counterproductive in the Darwinian struggle for progeny. Cicadas as a species are probably in the middle of a subtle evolutionary shift wherein those cicadas that mate on tree branches and in grass survive more often than those that mate on concrete. How genes could be involved in that particular behavior, I don't know. But I do know that fairly complex behaviors have genetic components. For example, type of tree branch used for nest site choice in birds can be genetic.
Obviously the cicadas were incapable of the complex thought process needed to see that mating on a sidewalk would get them both squished and that they should just move 6 inches to the left into the grass. Animals are not thought to behave rationally. That means they don't weigh the pluses and minuses of behavioral choices - they just act. This always brings me to the following questions: If animals don't actually decide what they are going to do, why do they do anything at all? And how do they know what they should be doing?
For behaviors to evolve, there has to be a way for animals to 'know' that they are choosing a good behavior versus a bad behavior. There must be something similar to pleasure and pain to reinforce good and bad choices. In fact, the hormone that causes pleasure and contentment in humans (oxytocin) has been found in animals. Animals also have adrenaline rushes, which elicit fear, panic and aggression in humans.
Unfortunately, there is no way to know what an animal actually feels, so we must come to conclusions by analogy. If oxytocin is released, the animal must feel something positive - perhaps calming or pleasurable, because that's how it works in people; if adrenaline is released, it must be the equivalent of scared, etc. An animal that feels pleasure when it swallows food, drinks water, mates and finds safe locations to rest will probably survive. An animal that feels fear when a larger, unfamiliar animal is near will respond by running away or fighting, both of which can extend life span.
My favorite example of how this might work involves a study of my least favorite organism: roaches. In a study to mimic roach behavior, scientists programmed tiny, roach-shaped robots to be still when they are in dark places and near other roaches and to run fast when they were in the light. With this simple behavioral program, the roaches ended up behaving almost identically to real roaches. I imagine that in real roaches' ganglia (little clusters of nerves throughout their bodies that act like little brains), they feel roach-y contentment in dark, tight spaces with buddies around, and they feel panic when the lights come on. Oddly enough, in a test to see if roaches have a stronger preference for darkness or being around their roach pals, they chose the social environment over the safe environment. Who knew roaches were such followers? More.
There must be at least a few cicadas out there with a mutation that makes them fear stepping on concrete and therefore move away quickly when they find themselves on it. The concrete-fear gene should confer an advantage to those cicadas, as they would be less likely to be scraped out of the treads of a tennis shoe one day. Assuming humans keep building and using concrete sidewalks, some day all the genes for sidewalk-mating will have been eliminated, and only the concrete-fearing cicadas will have survived. Cicadas as a species will be smarter, all without a single cicada having to think an actual thought.
Of course, humans always make their decisions based on cold rationality, because we have the ability to think and separate our emotions from our thoughts. We have evolved brains capable of weighing our options and choosing the best path, so we don't need instinctual behaviors. ...Not so fast! We have plenty of positively- and negatively- reinforced behaviors: pleasure for eating, playing, making a home and mating, and pain from loss, fighting and overwork. Humans have repeatedly been shown to act irrationally in less obviously evolutionary ways too. Some of us take unnecessary risks, get pregnant too young or fall in love with the wrong person. We have even learned that the average of millions of human decisions is not based on rational principles, as it is impossible to explain or predict the stock markets.
We must be careful not to fall into the trap of assuming humans are so different from other animals. There are evolutionary payoffs to many irrational behaviors. Risk-taking can result in big rewards in status and resources, and perhaps more mates to pass on risk-taking behaviors. Teen pregnancies tend to pass on genes early and often (not that I'm advocating teen pregnancy). Romantic decisions are made at least sometimes based on evolved chemical signals (pheromones and antibodies) that might signal compatibility and more healthy offspring. Human social tendencies can lead to careless financial decisions just as roach social tendencies can draw roaches into unsafe locations.
So how much of our behavior is instinct and how much is logic?