How to Flash Android 5.1 in Moto E XT1022
A custom recovery is a replacement recovery software for your device. It basically has a backup feature and a system for installing unsigned updates (flashable zips).

Factory reset is a wipe of your user data and cache partitions. It does not affect other partitions, and can be done via stock recovery.

Flashing a ROM can be done in two ways: fastboot or some flash tool for stock ROMs, and for custom ones, by flashing a ROM zip through a custom recovery. For the installation of a custom ROM, not one of its updates, these partitions should be wiped: system, data, cache (app data cache), and dalvik cache (app code cache). Further information depends on the particular variant of the device you are on.