None of Shakespeare's characters ever said that, sorry. The earliest example of the use of the proverb in exactly that form dates from 1721, long after Shakespeare's day. The idea was around in his...
The quotation is incorrect. It's a nursery rhyme, but the correct one is more like is "if wishes were horses then beggars would ride."
HOWEVER, there's a Bryan Adams song that not only uses that...