I think it will never work, since line 1 and 2 and line 5 and 6 have the same ID. There is no way of knowing for the SQL Server, which lines belong together.
Assuming you have ID 3 in line 5 and 6 you can use this query:
ID Action Value
1 BEGIN 1
1 END 5
2 BEGIN 20
2 END 25
3 BEGIN 10
3 END 15
select
b.id, b.value as [BEGIN], e.value as [END]
from
t1 b
inner join t1 e on b.id = e.id
where
b.action = 'BEGIN'
and e.action = 'END'
Result:
id BEGIN END
1 1 5
2 20 25
3 10 15