Analysis
To put it short and simple: by means of analysis we try to figure out "how music works".
When analyzing music we will concern ourselves with general principles of form, structure and texture in music as well as several basic and "iconic" form types and form procedures. It goes without saying (hopefully) that analysis is not a goal in itself, but serves "higher aims". (...).
My personal approach
I consider it important when analyzing music to use tools or approaches that give good results independent from the kind of music (style, genre, place in history). That is why I use working models based on the work of Hermann Erpf (Form und Struktur in der Musik, 1967) and Hans-Peter Schmitz (Singen und Spielen, 1958).
Erpf aligns well with (Gestalt-like) characteristics of human perception. Used key terms from Erpf are: unity & segmentation, form means, form principles and form characters. From both Erpf and Schmitz I derived the description of musical material in terms of the 5 parameters (pitch, duration, dynamics, colour, articulation). This is a tool that helps to describe factually what can be heard. In addition to Erpf I always pay attention to the texture of music.
This approach works well as a stepping stone towards more in-depth and specific analysis with regard to style and genre of the music at hand.
Musical analysis as a discipline has a relatively short history going back to the 19th century. Of course throughout history people have tried to understand music and the principles and patterns behind it (how to compose/write music and how to peform it), but as a theoretical/academic discipline it's rather young.
A very good article by Ian D. Bent and Anthony Pople in Oxford Music Online (Grove):
https://doi.org/10.1093/gmo/9781561592630.article.41862