These are two very different poems, and are so different in fact, that normally they are not selected for a compare/contrast question. However, one useful similarity that can be identified is through the structure. Both poems are written in iambic pentameter, although the actual form is very different. "If" is written in four stanzas of eight rhyming lines with a clear rhyme scheme and rhythm. "My Last Duchess," by contrast, is a dramatic monologue without any set rhyme scheme or rhythm.
Both poems also present a one-sided conversation. In "If," it is an older man who is talking to a younger man he refers to as his "son" about the qualities of being a "man":
If all men count with you, but none too much;
If you can fill the unforgiving minute
With sixty seconds' worth of distance run,
Yours is the Earth and everything that's in it,
And - which is more - you'll be a Man, my son!
In "My Last Duchess," however, we eavesdrop on a conversation between the Duke and somebody we come to realise is the servant of another Lord who wants to marry his daughter to the Duke. What is so shocking about this poem is the way that the Duke makes casual reference to the way that he had his last Duchess disposed of because he displeased her:
This grew; I gave commands;
Then all smiles stopped together. There she stands
As if alive.
The Duke clearly treats his wives just like his possessions, as museum pieces that he owns utterly and can do with as he wants. The dramatic monologue of this poem makes it incredibly sinister and disturbing, whereas in "If" the speaker, through the rhythm of his words and the rhyme scheme, is encouraging, upbeat and positive.