Usually you learn any language by listening, speaking, reading, writing.
Also wanted to highlight that sanskrit is not a dead language. By dead language, I assume that it is nobody really uses it actively.
I don't know about latin and other languages, but sanskrit is very much alive. The patronage decreased, but it seems to be making a comeback again.