Two pointers is the first pattern where the code is trivial and the justification is not. The code is four lines. The reason it is correct is an exchange argument, and if you cannot state it, you will not recognise the next problem that needs it.
The setup
Given a sorted array and a target, find a pair summing to the target. Start one pointer at each end. If the sum is too small, advance the left pointer. If it is too large, retreat the right one.
Why discarding is safe
Suppose a[lo] + a[hi] < target. The claim is that a[lo] cannot be part of any valid pair among the remaining elements. Here is the argument: a[hi] is the largest element still in play. Every other candidate partner for a[lo] is at an index below hi, and the array is sorted, so every one of them is less than or equal to a[hi]. If a[lo] paired with the largest available partner already falls short, it falls short with every smaller one too. So a[lo] participates in no remaining solution, and discarding it loses nothing.
The mirrored argument handles the other case: if the sum is too large, a[hi] paired with the smallest available partner still overshoots, so a[hi] is dead.
An element is paired with its most favourable remaining partner. If even that fails, the element cannot succeed with anything, so it can be eliminated. This is the reusable core.
Where it generalises
Container With Most Water is the same argument wearing different clothes. Area is limited by the shorter of the two walls, so moving the taller wall inward can never help: the width strictly shrinks, and the height is still capped by the short wall you kept. The shorter wall is the one paired with its most favourable partner — the farthest wall available — and it failed. Discard it.
When it does not apply
The argument depends on sortedness, or on some monotone structure that plays the same role. On an unsorted array, a[hi] is not the largest remaining element, so 'paired with its most favourable partner' is false and the whole thing collapses. That is why unsorted Two Sum wants a hash map instead — you give up the structure, so you pay in space.
A test for yourself
Before writing a two-pointer solution, answer: which pointer am I about to discard, what is the most favourable partner it currently has, and why does failing against that partner mean it fails against everything? If you cannot answer in one sentence, the problem probably is not a two-pointer problem.
Reading about a pattern is not the same as producing it under time pressure. The problems that drill this are in the curriculum, in order.