**Ca3799 **is close to the simplest answer.
Birds typically do this as a defense of territory; they see their reflection, and try to drive it away. The action is also self reinforcing: every time the bird flies past the window, there is that darned competitor again, so the bird learns to check the location of the window ever more frequently.
Removing the reflection for a period of time helps to break this cycle. Without reinforcement for a week or so, the behavior often disappears entirely. A sheet of paper taped to the outside of the window will work, but it probably won’t cover the whole window, and it may be hard to keep in place if wind or rain occur.
We recommend taking some dry laundry powder and mixing it with a small amount of water, which in the right proportions will produce a thick, white “paint”. (Show you how ancient I am, back in my day we used this to write FOR SALE on car windows and such.) Wipe this on the outside of the window and the reflection disappears. Leave it on for a week or so until the bird forgets about that particular intruder to its territory. Then hose it off and you get a clean window.
If it’s a large window, usually just “painting” the lowest 8 or 10 inches will suffice, since the bird will land on the sill to do battle – at which point, the enemy disappears!