Be prepared for this dumb question

Okay so I'm aware this question may be (is) dumb, but I'm so curious. In the middle of the night I get really thirsty and drink some water. Not long after that I have to pee really bad. I always avoid drinking water at night for this reason. But why do you pee it out? Isnt your body going to put that water to use if you're dehydrated? Clearly I know nothing but if you know the answer that would be great, lmao😂 posting anonymously because I'm embarrassed

Edit: thanks everyone! Lol yes I pee during the day... I was just curious as to why I always had to pee really bad at night 😜