4 Forgot to update the TIO..

# Java 8, 88 87 bytes

n->{for(int c=0,s=0,d,N=n;c!=2;s++)for(c=d=1,n+=n<N?s:-s;d<n;)if(n%++d<1)c++;return n;}


Port of @NaturalNumberGuy's (first) C answer, so make sure to upvote him!!
-1 byte thanks to @OlivierGrégoire.

Explanation:

n->{               // Method with integer as both parameter and return-type
for(int c=0,     //  Counter-integer, starting at 0
s=0,     //  Step-integer, starting at 0 as well
d,       //  Divisor-integer, uninitialized
N=n;     //  Copy of the input-integer
c!=2;        //  Loop as long as the counter is not exactly 2 yet:
s++)         //    After every iteration: increase the step-integer by 1
for(c=d=1,     //   (Re)set both the counter and divisor to 1
n+=n<N?    //   If the input is smaller than the input-copy:
s      //    Increase the input by the step-integer
:       //   Else:
-s;    //    Decrease the input by the step-integer
d<n;)      //   Inner loop as long as the divisor is smaller than the input
if(n%++d     //    Increase the divisor by 1 first with ++d
<1)  //    And if the input is evenly divisible by the divisor:
c++;       //     Increase the counter-integer by 1
return n;}       //  Return the now modified input-integer as result


# Java 8, 88 87 bytes

n->{for(int c=0,s=0,d,N=n;c!=2;s++)for(c=d=1,n+=n<N?s:-s;d<n;)if(n%++d<1)c++;return n;}


Port of @NaturalNumberGuy's (first) C answer, so make sure to upvote him!!
-1 byte thanks to @OlivierGrégoire.

Try it online.

Explanation:

n->{               // Method with integer as both parameter and return-type
for(int c=0,     //  Counter-integer, starting at 0
s=0,     //  Step-integer, starting at 0 as well
d,       //  Divisor-integer, uninitialized
N=n;     //  Copy of the input-integer
c!=2;        //  Loop as long as the counter is not exactly 2 yet:
s++)         //    After every iteration: increase the step-integer by 1
for(c=d=1,     //   (Re)set both the counter and divisor to 1
n+=n<N?    //   If the input is smaller than the input-copy:
s      //    Increase the input by the step-integer
:       //   Else:
-s;    //    Decrease the input by the step-integer
d<n;)      //   Inner loop as long as the divisor is smaller than the input
if(n%++d     //    Increase the divisor by 1 first with ++d
<1)  //    And if the input is evenly divisible by the divisor:
c++;       //     Increase the counter-integer by 1
return n;}       //  Return the now modified input-integer as result


# Java 8, 88 87 bytes

n->{for(int c=0,s=0,d,N=n;c!=2;s++)for(c=d=1,n+=n<N?s:-s;d<n;)if(n%++d<1)c++;return n;}


Port of @NaturalNumberGuy's (first) C answer, so make sure to upvote him!!
-1 byte thanks to @OlivierGrégoire.

Try it online.

Explanation:

n->{               // Method with integer as both parameter and return-type
for(int c=0,     //  Counter-integer, starting at 0
s=0,     //  Step-integer, starting at 0 as well
d,       //  Divisor-integer, uninitialized
N=n;     //  Copy of the input-integer
c!=2;        //  Loop as long as the counter is not exactly 2 yet:
s++)         //    After every iteration: increase the step-integer by 1
for(c=d=1,     //   (Re)set both the counter and divisor to 1
n+=n<N?    //   If the input is smaller than the input-copy:
s      //    Increase the input by the step-integer
:       //   Else:
-s;    //    Decrease the input by the step-integer
d<n;)      //   Inner loop as long as the divisor is smaller than the input
if(n%++d     //    Increase the divisor by 1 first with ++d
<1)  //    And if the input is evenly divisible by the divisor:
c++;       //     Increase the counter-integer by 1
return n;}       //  Return the now modified input-integer as result

3 added 60 characters in body

# Java 8, 8888 87 bytes

n->{for(int c=0,s=0,d,r=n;for(;cN=n;c!=2;s++)for(c=d=1,r+=r<nn+=n<N?s:-s;d<r;s;d<n;)if(r%++d<1n%++d<1)c++;return r;n;}


Port of @NaturalNumberGuy's (first) C answer, so make sure to upvote him!!
-1 byte thanks to @OlivierGrégoire.

Try it online.

Explanation:

n->{               // Method with integer as both parameter and return-type
for(int c=0,         //  Counter-integer, starting at 0
s=0,    s=0,     //  Step-integer, starting at 0 as well
d,    d,       //  Divisor-integer, uninitialized
r=n;    N=n;     //  Result-integer, startingCopy atof the input-integer
for(;c    c!=2;        //  Loop as long as the counter is not exactly 2 yet:
s++)         //    After every iteration: increase the step-integer by 1
for(c=d=1,     //   (Re)set both the counter and divisor to 1
r+=r<nn+=n<N?    //   If the resultinput is smaller than the input-copy:
s      //    Increase the resultinput by the step-integer
:       //   Else:
-s;    //    Decrease the resultinput by the step-integer
d<r;d<n;)      //   Inner loop as long as the divisor is smaller than the resultinput
if(r%++dn%++d     //    Increase the divisor by 1 first with ++d
<1)  //    And if the resultinput is evenly divisible by the divisor:
c++;       //     Increase the counter-integer by 1
return r;n;}       //  Return the resultnow modified input-integer as result


# Java 8, 88 bytes

n->{int c=0,s=0,d,r=n;for(;c!=2;s++)for(c=d=1,r+=r<n?s:-s;d<r;)if(r%++d<1)c++;return r;}


Port of @NaturalNumberGuy's (first) C answer, so make sure to upvote him!!

Try it online.

Explanation:

n->{               // Method with integer as both parameter and return-type
int c=0,         //  Counter-integer, starting at 0
s=0,         //  Step-integer, starting at 0 as well
d,           //  Divisor-integer, uninitialized
r=n;         //  Result-integer, starting at the input
for(;c!=2;       //  Loop as long as the counter is not exactly 2 yet:
s++)         //    After every iteration: increase the step-integer by 1
for(c=d=1,     //   (Re)set both the counter and divisor to 1
r+=r<n?    //   If the result is smaller than the input:
s      //    Increase the result by the step-integer
:       //   Else:
-s;    //    Decrease the result by the step-integer
d<r;)      //   Inner loop as long as the divisor is smaller than the result
if(r%++d     //    Increase the divisor by 1 first with ++d
<1)  //    And if the result is evenly divisible by the divisor:
c++;       //     Increase the counter-integer by 1
return r;}       //  Return the result-integer


# Java 8, 88 87 bytes

n->{for(int c=0,s=0,d,N=n;c!=2;s++)for(c=d=1,n+=n<N?s:-s;d<n;)if(n%++d<1)c++;return n;}


Port of @NaturalNumberGuy's (first) C answer, so make sure to upvote him!!
-1 byte thanks to @OlivierGrégoire.

Try it online.

Explanation:

n->{               // Method with integer as both parameter and return-type
for(int c=0,     //  Counter-integer, starting at 0
s=0,     //  Step-integer, starting at 0 as well
d,       //  Divisor-integer, uninitialized
N=n;     //  Copy of the input-integer
c!=2;        //  Loop as long as the counter is not exactly 2 yet:
s++)         //    After every iteration: increase the step-integer by 1
for(c=d=1,     //   (Re)set both the counter and divisor to 1
n+=n<N?    //   If the input is smaller than the input-copy:
s      //    Increase the input by the step-integer
:       //   Else:
-s;    //    Decrease the input by the step-integer
d<n;)      //   Inner loop as long as the divisor is smaller than the input
if(n%++d     //    Increase the divisor by 1 first with ++d
<1)  //    And if the input is evenly divisible by the divisor:
c++;       //     Increase the counter-integer by 1
return n;}       //  Return the now modified input-integer as result

2 Changed explanation: counter makes more sense than flag

# Java 8, 88 bytes

n->{int f=0c=0,s=0,d,r=n;for(;f;c!=2;s++)for(f=d=1c=d=1,r+=r<n?s:-s;d<r;)if(r%++d<1)f++;returnc++;return r;}


Port of @NaturalNumberGuy's (first) C answer, so make sure to upvote him!!

Explanation:

n->{               // Method with integer as both parameter and return-type
int f=0c=0,         //  FlagCounter-integer, starting at 0
s=0,         //  Step-integer, starting at 0 as well
d,           //  Divisor-integer, uninitialized
r=n;         //  Result-integer, starting at the input
for(;f;c!=2;       //  Loop as long as the flagcounter is not exactly 2 yet:
s++)         //    After every iteration: increase the step-integer by 1
for(f=d=1c=d=1,     //   (Re)set both the flagcounter and divisor to 1
r+=r<n?    //   If the result is smaller than the input:
s      //    Increase the result by the step-integer
:       //   Else:
-s;    //    Decrease the result by the step-integer
d<r;)      //   Inner loop as long as the divisor is smaller than the result
if(r%++d     //    Increase the divisor by 1 first with ++d
<1)  //    And if the result is evenly divisible by the divisor:
f++;c++;       //     Increase the flagcounter-integer by 1
return r;}       //  Return the result-integer


# Java 8, 88 bytes

n->{int f=0,s=0,d,r=n;for(;f!=2;s++)for(f=d=1,r+=r<n?s:-s;d<r;)if(r%++d<1)f++;return r;}


Port of @NaturalNumberGuy's (first) C answer, so make sure to upvote him!!

Try it online.

Explanation:

n->{               // Method with integer as both parameter and return-type
int f=0,         //  Flag-integer, starting at 0
s=0,         //  Step-integer, starting at 0 as well
d,           //  Divisor-integer, uninitialized
r=n;         //  Result-integer, starting at the input
for(;f!=2;       //  Loop as long as the flag is not 2 yet:
s++)         //    After every iteration: increase the step-integer by 1
for(f=d=1,     //   (Re)set both the flag and divisor to 1
r+=r<n?    //   If the result is smaller than the input:
s      //    Increase the result by the step-integer
:       //   Else:
-s;    //    Decrease the result by the step-integer
d<r;)      //   Inner loop as long as the divisor is smaller than the result
if(r%++d     //    Increase the divisor by 1 first with ++d
<1)  //    And if the result is evenly divisible by the divisor:
f++;       //     Increase the flag-integer by 1
return r;}       //  Return the result-integer


# Java 8, 88 bytes

n->{int c=0,s=0,d,r=n;for(;c!=2;s++)for(c=d=1,r+=r<n?s:-s;d<r;)if(r%++d<1)c++;return r;}


Port of @NaturalNumberGuy's (first) C answer, so make sure to upvote him!!

Try it online.

Explanation:

n->{               // Method with integer as both parameter and return-type
int c=0,         //  Counter-integer, starting at 0
s=0,         //  Step-integer, starting at 0 as well
d,           //  Divisor-integer, uninitialized
r=n;         //  Result-integer, starting at the input
for(;c!=2;       //  Loop as long as the counter is not exactly 2 yet:
s++)         //    After every iteration: increase the step-integer by 1
for(c=d=1,     //   (Re)set both the counter and divisor to 1
r+=r<n?    //   If the result is smaller than the input:
s      //    Increase the result by the step-integer
:       //   Else:
-s;    //    Decrease the result by the step-integer
d<r;)      //   Inner loop as long as the divisor is smaller than the result
if(r%++d     //    Increase the divisor by 1 first with ++d
<1)  //    And if the result is evenly divisible by the divisor:
c++;       //     Increase the counter-integer by 1
return r;}       //  Return the result-integer

1