Did you make sure you have understood what assimilation means in general, not only, as you said, "in this context"? I think this task is pretty straightforward if you stick close to the definitions and go through them step by step.
An assimilation is a phonological process by which a sound segment is made more similar to one of its neighbouring sounds with respect to at least one feature.
(Assimilation mostly occurs to make pronounciation easier - however, this is not part of the definition, this observation is perceptually-driven, as @user6726 points out.)
For consonants, those features are:
- place of articulation
- manner of articulation
Assimilation in this example
To solve the exercise, you now just need to check those conditions step by step:
- place of articulation:
- the original [n] is alveolar
- the neighbouring [b] is bilabial
- the resulting [m] is bilabial
At this point you are actually already done: You can see that the [n] is made more similar to [b] with respect to place of articulation, namely that [m] is a bilabial sound which [b] is as well. This is why the change from /n/ to [m] is an instance of assimilation.
This makes sense, intuitively: It is easier to pronounce the sequence [mb] where you lips and tongue are already in the right place rather than [nb] where you first have to move your tongue and then close your lips to produce both sounds.
We could of course also check for other features:
- manner of articulation:
- [n] is a nasal
- [b] is a plosive
- [m] is a nasal
- => the manner of articulation is not assimilated to [b]
- [n] is voiced
- [b] is voiced
- [m] is voiced
- => voicing is not assimilated either because [n] and [m] already are both voiced
(This is only the case for this particular instance; of course, voicing might look different in sound clusters like /N-p/ or /N-k/. But since voicing is in general a feature set with respect to which consonants can be classified and compared, I thought it to make the reasoning steps more complete.)
You can now also see why the assimilations are different in the other examples:
- In the case of "ungrateful", we have a neighbouring [n] and [g], where [n] is alveolar, [g] is velar and the reulting [ŋ] is velar => [n] is again assimilated to [g] w.r.t. place of articulation; this time not bilabial but velar.
Obiously, it wouldn't make sense to turn the [n] into a [m] here when the next sound you want to pronounce is [g]; correspondingly, it wouldn't help either to make [n] a [ŋ] when you then want to pronounce a [b], in fact a [ŋ] would be even worse as its place of articulation is even further away.
- In the case of "undeniable", [n] and [d] are both already alveolar - assimilation is applied, but vacuously, i.e. without it making a visible change to the previous version.
Again, in this word [n] is not made a [m] because this wouldn't make it easier to pronounce the sequence [nd].
Other instances of assimilation
This example uses only place of articulation as a feature for assimilation.
There are of course other types, where e.g. unvoiced consonants become voiced between vowels.
Also, assimilation can not only apply to consonants but also to vowels: Vowel harmony, which occurs e.g. in Hungarian, Finnish and Turkish, makes vowels more similar with respect to horizontal tongue position, i.e. within a word there should only occur either only front or only back vowels, and when appending an affix (all of those three languages are agglutinative languages), there is usually two variants of them, one with a front and one with a back vowel where the one which more similarity (front/back) to the other vowels in the word is chosen, or if you want to use underspecification, there is one underspecified underlying affix which may be realised in a different way if the context requires so.
The underlying, underspecified phoneme is /N/ (note the capitalisation, reflecting its underspecified status) which is, by the use of a phonological assimilation rule, realised as the sound [m] in a context where it is followed by a [b].
Using undrespecification of the prefix, one could take "uN-" (/ʌN/) as the underspecified prefix, which then, by a phonological assimilation rule, gets realised as either [ʌn], [ʌm] or [ʌŋ] depending on the phonetic context.
For the rule notation, you could start out as follows:
/n/ -> [m] / _[b]
To make the rule a more formal and generative one, you should now try and abstract away from the concrete phoneme lables ([n m b]) by using distinctive features instead (such as [+cons], [LAB] etc.), but I hope you will be able to do this by yourself from what I wrote.
I hope this answers your question.
Again, I really think it would help to take a look at the definition of assimilation again and then just apply the feature checks step by steps, the difference between the examples becomes very clear then.
P.S.: To quickly type phonetic symbols (since one unfortunately can't TeX in the editor here...), you can use IPA typeit and then simply copy-paste the text.