Senior judges deliver humiliating defeat for Government on surveillance powers but police warn it means it will make it harder to trace vulnerable people