glfwSwapBuffers only works when spammed

I’m trying to learn the basics of openGL.
in the tutorial i was watching glfwSwapBuffers is called once and works, however i need to call it a lot of times or it does nothing. am I doing something wrong? how is it supposed to work

code im running vvv

gladLoadGL();
glViewport(0, 0, 500, 500);

glClearColor(1.0, 0.0, 0.0 , 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glfwPollEvents();
glfwSwapBuffers(window);//does nothing
glfwPollEvents();
int x = 151;

for(int y = 0; y < 100; y++){
    glfwSwapBuffers(window);//doesnt work below 100
    glfwPollEvents();
}
glClearColor(0.0, 0.0, 1.0 , 1.0);
glClear(GL_COLOR_BUFFER_BIT);

while(!glfwWindowShouldClose(window))
{    
    glfwSwapBuffers(window);//works
    glfwPollEvents();    
}

You only need to call glfwSwapBuffers(window) once per frame. For a basic OpenGL with GLFW program see the example in the Getting Started guide.