Why does the YouTube app know what I have watched on youtube.com in Safari
Your YouTube history is affiliated with your Google account. This is the same affiliation that allows you to keep track of your liked videos and any playlists you may make and channels you subscribe to. Any browsers/apps which are logged into your Google account will have the same information about your view history.