- Your examples are not consistent - you have added an adjective (uncanny) to the second one. This will lead to difficulties in the explanation, so I will take the examples as
This program has the ability to adapt to its user.
The is, in basic terms, a demonstrative adjective that is related to the demonstrative adjective that.
Whereas that is used when pointing at something, the is used with a noun that is
(1) already known by the listener ("The moon is bright" = we all know what "the moon is),
or
(2) is about to be described by the speaker ("The tree in my garden is tall." - I have described the tree - it is the tree in my garden and not any other tree.
The is used to indicate that the noun it qualifies is a specific noun.
*(We could say "This program has that particular ability [that allows it] to adapt to its user. but the does that job for us.)
- This program has an ability to adapt to its user.
A/an is, in basic terms, an adjective of quantity. It is related to "one".
"A/an noun" means "one example of a noun" or "one example from among many examples of a noun" - a/an is non-specific.
(We could say " This program has one ability amongst many of its abilities to adapt to its user.)