use a id number which my database doesn't have
Then add it.
SQL is a language of sets: https://en.wikipedia.org/wiki/Set_(mathematics)
By definition, elements in the set are not located left or right to one another, to the North or to the South, or before and after. They just exists. In unordered way.
So, if you want your rows ordered - then you have to ADD some ordering value (field, column) into it, and then populate that value. And then reading from the table, if you want it, you may ask to order the results by that value.
As of now, Firebird has all the rights to read rows in any order it might like, even to change the order of the rows on disc (it will not, but that is implementation ndetail and it may change in future).
You have to add some ID column and then to populate it.
This would make "last record" or "prior record" or "row above" meaningful idioms: "object with ID one less than ID of current object". As of now in SQL terms there is no any meaning in "last record" and reliable formulating a query is not possible.
After that changing the flag column in the table becomes a trivial MERGE
statement.
MERGE INTO MyTable T1
USING MyTable T2
ON (T2.ID = T1.ID - 1) AND (T2.pos_buildcount <> 255)
WHEN MATCHED THEN
UPDATE SET T1.flag = 1
http://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-dml-merge.html
Or, without adding the column into the table, but making a "virtual" column in the query, joining the table upon itself.
https://en.wikipedia.org/wiki/Join_(SQL)#Left_outer_join
SELECT T1.*, T2.Vehicle as Flag
FROM MyTable T1
LEFT JOIN MyTable T2
ON (T2.ID = T1.ID - 1) AND (T2.pos_buildcount <> 255)
Granted it would only work if ID column would be filled with integers with no gaps. Otherwise there would be other definitions what "prior record" means than T2.ID = T1.ID - 1
, but the idea holds. Define what "prior" means in terms of real data on real columns and then you can compare the table with itself.