When you define a function like draw_square, anything you make inside of that function stays inside of it. In this case, you say
def draw_square():
window = turtle.Screen()
That's fine, but outside of the function, there is no such thing as window. So you should then get an error when you try window.bgcolor("red").
You have two choices: (1) delete that function line and unindent the definition of window; (2) indent everything after the definition, so that it is also inside the function, then call the function with draw_square() after you've defined it.
Another problem: wait_for_user() is not defined. Is this a method of brad, or window, or a function inside turtle?
This works for me:
import turtle
def draw_square():
window = turtle.Screen()
window.bgcolor("red")
brad = turtle.Turtle()
brad.forward(100)
brad.right(90)
window.exitonclick()
draw_square()