If you like and dislike a photo, Instagram will remove the notification immediately. You must do this before the person sees the notification on the screen. However, if the person who owns the account looks at their phone when you accidentally hit the like button and notifications are enabled, they will find out about the action!
===============================