It was likely an optical effect that you saw directly, and whatever physical object was generating the original light source it was likely not moving in the way that you observed (or potentially there were multiple objects, becoming bright in sequence - a meteor-like object that broke up before its pieces became bright enough to see might match your description). Either way, in the canonical meaning of "Unidentified Flying Object" then yes you observed a UFO - something in the sky that you could not identify.
I don't think this site could even attempty to further identify your observation without specific details of accurate time, location. A still image or video might help categorise it - even if it is a rare kind of event, astronomers spend a lot of time looking up and may have observed something similar.
It is worth checking against some lists of standard things that can get classified as UFOs: https://www.skyatnightmagazine.com/space-science/10-things-we-mistake-for-ufos/ - if one seems plausible to you, try to find a video of it, see if it looks similar enough to match what you saw.