Dishwasher Leaking froim Underneath at the Float Switch

this leak only happens sometimes, but every once in a while i will get a puddle of water on my kitchen floor. i opened up the toe panel and located the leak while it was happeneing and it was coming directly from the float switch directly underneath the float that is in the didhwasher. what does it mean that this only leaks sometimes? if its a bad switch shouldnt it leak all the time? what causes a leak from the float switch? any help would be appreciated!! thanks