Hi Aswit,
Looks like the URI handler is acting on the result too early in 5.1. The tunnel does come up (that's the VPN icon you see a few seconds later), but onerror/close runs before the connect finishes, so close kills the app and onerror makes a working connection look like it failed.
There's an old onerror/onsuccess bug, CSCui07396, but that one's logged against the Android client so it isn't really yours. I haven't seen this exact iOS behaviour written up anywhere, and there are a couple of other 5.1 iOS app issues people have raised here, so I'd open a TAC case with your versions (5.1.16.264, iOS 26.5) and the two repro steps.
For now, take anyconnect:close out of onsuccess/onerror, since that's what's closing it mid-connect. If you can get hold of an older 5.1 build, try it and see which version broke it, that'll help the case. iOS 26.5 is also very new so worth flagging both to Cisco.