There are two ways to simplify work with vertical spacing: a hard grid and a soft grid. A hard grid means that the height and spacing of the elements are always multiples of a grid unit. A soft grid does not limit the height of the elements in any way, but only defines multiples of the spacing between them.
In the design of sites and web applications soft grid is preferred. It gives more freedom in making design decisions and does not impose such restrictions as a hard grid.
There are several types of grids: column, modular, hierarchical and others. Each type of grid can solve a particular problem. It all depends on the content and design requirements.
It is quite normal to combine different types of grids in one layout if the task requires it.
There is no need to fit the sidebar into the page grid. The sidebar may well be separate from the overall grid, or it may have its own grid.
Often the sidebar has a fixed pixel width, and the content area stretches according to the width of the page. In that case, it's difficult to fit the sidebar into the grid. And there is no point to do that.
There is no need to fit the header into a single page grid. First, the header is usually a line, not a column module, and the default line does not require a grid. Second, it's quite difficult because the header can have a wide variety of elements, menus, and logos that you can't fit into a single column.
So unless the content requires a direct relationship between the page columns and the header, there's no point in fitting it into the overall page grid. You can do without the grid in the header or make your own grid for it. The same goes for footer.
There is no point in using a 12-column grid if 3 columns or any other number of columns is right for the content.
It's perfectly normal to combine several grids in one layout, in one page, in one application. If the content requires different approaches, that's fine and allows you to build the most effective layout possible.
You shouldn't always fit content into the one grid. It's not the grid that dictates the terms, it's the content.
The grid is just a tool for organizing content. It's one way to build interfaces more efficiently, especially multi-page UI. The grid gives format and structure to speed up and simplify content.
If the content doesn't need to be grid-based, you shouldn't artificially create limits that don't make sense.