Anything haphazard is random, disorganized, slipshod, or hit-or-miss. A tent erected haphazardly might look more like a big nylon bag of dirty laundry than a place to sleep.
Ever heard the expression "I'll hazard a guess?" In it, the word hazard means "chance," as in "take a chance." Think of the hap in haphazard as short for "happen." Combine hap- and -hazard and you get something that happens (or appears to have happened) by chance. If you approach a math problem with haphazard reasoning, you're likely to get it wrong.