If there is no RAR response from eNB/gNB will UE keep sending msg1 till preambleTransMax?

You miss the point: T3402 is only for attach procedure. Not for regular traffic procedure.

No, I didn’t say that it is for regular traffic.

No doubt T3402 is NAS timer and nothing to do with traffic/rach directly.

For NAS layer, 5 Attach request failure will start T3402.
Now to send actual attach request UE lower layer has to complete RACH first. So altimately rach failure during initial attach is converting to attach request failure for NAS, which in turn causes T3402 to start.

Counted as Lower Layer failure in 24.301.

It does not say attach request failure.
It says attach failure, that could be that UE got an answer of attach reject not necessary due to RACh failure like you mention.

See the cause of T3402 start:

T3402 can be caused by wide range, can be attach failure, RRC rel before attach accept, rach failures.

Attach failure could also means 5 attach reject, not 5 attach failure due to rach.

Indeed, can be attach reject as well, example #17.
Or non integrity protected attach rejects.

What do you mean by attempt counter here?

My understanding is NAS decides to send attach request is attach attempt.

NAS decides attempt attach → lower layer trigger rach → rach success and actual content of attach request sent OTA → rrc connection reconf/ reconf fail/ rrc release/ rlf → attach accept/reject recived by UE NAS

In above flow, after 1st (bold letter) step, any failure can cause attach failure which triggers T3402.

It has to be 5 failures to trigger T3402. Failures could include attach rejects. T3402 is not directly related to rach failure. Once again, T3402 is a NAS timer not an AS timer.