jtag is primarily for boundary scan test.
it tests whether the device is functioning properly or not.
but it is used for another purpose which is very popular. it is used for programming and emulation of digital chips. (emulation is seeing what is happening in the chip while running).
not all types of digital systems support jtag. a system or chip should have jtag capability for you to use it.
usually chips and systems that support it, maintain a software for test/programming/emulation with their product