To ensure that compilation albums are kept together, there are three separate tags (or fields) that need to be correctly completed:
- album artist - (not the artist tag)
- compilation - (make sure to read the Special Note* in the compilation paragraph below)
- album - (the album's title)
and it's the compilation flag that can catch people out.
The album artist tag:
iTunes is fussy about compilation albums and it needs the album artist tag to be filled in (for every song on the album) with the text Various Artists in order to keep the album together.
Where it differs from at least one other music management programme that I know of is that it isn't fussy about this tag for single-artist albums. On a single-artist album, the album artist tag can be empty and iTunes does not complete that tag by default. Every time you add a compilation (various artists) album to your iTunes Library, you need to check that this tag is correct. It probably won't be until you change it.
The compilation tag:
In order to keep a compilation album together, the compilation tag must be set on for each song on the album. A common problem can be that some songs on the album are are marked (set), while others are not. That will cause the album to be split up.
To check this:
- select all the songs on the album and use iTunes' top bar menu to choose Edit/Get Info (and answer "yes" to the question about editing multiple items)
- this opens the Details tab; look for the compilation tag towards the bottom of the pane
- there must be a tick in the box. Note that I specifically do not use the word "checkmark", with which you may be more familiar. See the screenshots below. In all four of the pictures, the view shows the Edit Items panel for two or more songs on an album:

and

If you see the dash mark, do not think of it as a "checkmark". It indicates that one or more of the selected songs does not have the tick mark in it. If you see this, the remedy is to click the box twice. The first time will leave the box empty and the second will add the tick to the box and therefore to every song. You will see a green "tick in a circle" icon to the right, as shown below:

Tap the OK button, which is lower down and not shown in the screenshot
Finally, here's the same view if none of the selected songs has the compilation flag ticked:

To add the tick for a compilation album, simply click on the box once and tap the OK button.
* Special Note: as far as iTunes is concerned, a Greatest Hits or Best of album by one artist is not a compilation album. Unfortunately, the Gracenote database that iTunes uses to complete these tags for CDs that you copy into your library may have the compilation flag turned on for this type of album. If it's on, you need to turn it off for all the songs on the album.
The Album tag:
To keep an album together, every track on the album must have the same title. This may seem obvious, but see the next section.
Trailing spaces (in any and all common tags):
The suggestion that you refer to about the trailing character is a real problem, which is why it has been mentioned. It's very easy to have a space after the text in a common tag (such as the album title), but very difficult to spot.
If you think this is the issue in any of the common tags, try the following:
- select all the songs on the album
- highlight the tag that you suspect may have a trailing space by selecting from the end of the text, back to the start. If the blue highlight extends beyond the last letter, there is a trailing space:

and

If you cannot spot the extra gap after the word Break in the two screenshots above, that just shows how difficult it is to spot. This tip is not full proof, it's possible to highlight the text but still not include that "space".
The remedy is to copy the text from one song and paste what you copied into every song on the album.
First of all, check the compilation flag. It's almost certain to be the cause of a split up compilation album. Then check the album artist tag.