"Cadence" is bike-speak for crank speed in RPM. Most riders find that pedaling feels best in a fairly narrow cadence range that generally changes little with riding conditions. For non-racers, this self-selected cadence is usually just below the cadence for max leg power and not far from the cadence for max metabolic efficiency.
So, not a bad idea to find your own preferred cadence and then use various combinations of gears and assist levels to stay there as conditions change. I strongly recommend giving this a try.
A cadence sensor helps, but you can also apply this approach by feel if you pay attention. If your bike has no built-in cadence sensor, it's easy and cheap enough to add one and monitor it with a phone app like RideWithGPS
My knees strongly prefer a cadence of 80±5 RRM, and my leg muscles are happy there, too. I tend to ride at low assist and maintain cadence first with my gears and then with PAS. But that's just my preference. You'll use more battery and get less exercise the other way around (assist first, then gears), but those may not be concerns on some rides.
Of course, you can also maintain cadence by adjusting gears and assist at roughly the same time. For example, my ebike offers 9 assist levels, and I really like the finer control that provides. When cadence starts to get too high under acceleration, I often go up one gear and one assist level at the same time. Result: Higher yet sustainable speed at preferred cadence.
I still prefer to avoid shifting (up or down) at the high chain tensions encountered when pedaling up steep hills, into stiff headwinds, or under heavy accelerations. Easing up on the pedals for a moment is one way to reduce chain tension for a shift. How much drivetrain wear and tear you'd actually save during gentle accelerations in your flat terrain is debatable, but it's still a good habit to develop.
If you have a rear hub-drive with a throttle, you can also reduce chain tension for shifts by blipping the throttle instead of easing up on the pedals. This approach minimizes shift-related momentum loss on hills and in headwinds. (NB: On a mid-drive, this increases chain tension.)