Generally speaking, eBikes come in three classifications (see the table below), and these classifications are often used to determine where an eBike can be used. For example, can you ride your eBike on a federal forest trail, can you ride your eBike on a state bike trail, etc. The classifications define maximum speed of the motor and whether there is a throttle or not. Note that the classification model is not necessarily used consistently everywhere. For example, sometimes the classification system also includes a maximum wattage on the motor, so be sure to check your local laws and regulations. This website has some additional information on where eBikes might be allowed for each state.
You can also find Class 3 eBikes that can be placed into a Class 1 mode to limit their speed to 20 mph. This would potentially allow you to use the higher Class 3 speed when in traffic or unregulated locations, and also place it in "Class 1" mode when riding on trails that only allow Class 1 bikes. Additionally, some Class 2 bikes have detachable throttles, allowing them to behave as a Class 1 bike. Be aware that eBikes that work in multiple modes may still not be legal to ride on a Class 1-only trail. It's also worth mentioning that while most states will have a law that indicates whether or not a certain class eBike can ride on different trail types, almost all of them also include provisions that allow a local trail to determine what is allowed on that specific trail system, so always check the regulations for the specific location you are biking.
Class 4 eBikes have higher wattage motors, and/or go faster than 28 mph. Class 4 e-bikes are not permitted for road use, as their top speed is greater than 28mph and motor output is greater than 750W. This puts them in the same category as electric dirt bikes, the difference being is that Class 4 e-bikes have pedals, while dirt bikes do not. Personally, I don't think of these as "bikes" or "ebikes", I think of them as eMotorcycles.
Recommendation: I recommend most people select a Class 1 or Class 2 eBike, both for practicality and for greater acceptance on trails. For most casual riders, the extra 8 mph of the Class 3 bike are not going to be used significantly (I go into more specific detail of my Class 1 vs Class 3 bike experiences here). In general the number of trade-offs with a Class 3 eBike (higher cost, shorter battery life, less trail compatibility) are not worth it. The primary exception would be people who are regularly commuting longer distances.