The term is used to define several things. Usually, it means overwriting one of your phone's partitions with an image you may have downloaded elsewhere. It usually extends to installing many other things, such as root or another OS on your phone.
Specifically flashing your phone usually means you're doing one of the following:
- Restoring your phone to the stock firmware, in other words, make it as it was originally
- Installing a custom recovery, which allows you to do things like make a backup of any part of your phone, root your phone, install or flash zips containing a custom operating system and many others
- Usually done after installing a custom recovery (and depending on the phone), the recovery allows you to "flash" arbitrary files. One of these may be a file which "roots" your phone, allowing you to do many things that are usually blocked because they require "Superuser" permission. For instance, you'll be able to manually uninstall applications that come pre-installed with your phone, perform a full backup of your phone, and many others.
- Installing a custom operating system in order to obtain a customized experience, get rid of bloatware, or any other reason. Usually done after installing a custom recovery