Get Last Id before insert in dbtable

please note that last is collection https://book.cakephp.org/3.0/en/core-libraries/collections.html#Cake\Collection\Collection::last method not query, so when you

$this->Users->find()->select(['id'])->last();

it generates

Debug: duration=0 rows=4 SELECT Users.id AS `Users__id` FROM users Users

so you get ALL rows and collection just gives you last one

EDIT for clarification:
first is https://api.cakephp.org/3.8/class-Cake.Datasource.QueryTrait.html#_first