Like others have said it could see itself and want to mate/fight, or see trees and think it can get to them. It could also be going after bugs. We get a lot of birds who fly around the windows and gutters/eaves snagging bugs. We also have birds who know the window is our house and will come and stare in at us when the feeders are empty. But Robins have never done this! We do have to remove many nests each year right as they start making them because they just LOVE to nest where they shouldn't like right in the middle of the treads on our stairs out the back door! But I think the birds think our house as something safe so they tend to almost want to move right in!