How does setting takeoff flaps improve aircraft performance?
I think the term "takeoff performance" in that context means takeoff distance and departure gradient for obstacle clearance.  Obviously, takeoff distance is shorter with takeoff flap than without.  And a departure with takeoff flap will generally, depending on the airplane, have a steeper gradient than without, even though the total climb rate is degraded with takeoff flap out.  On an IFR departure, or a regular airplane clearing trees at the end of the runway for that matter where you fly at best angle instead of best rate, gradient is the key performance factor, not so much rate of climb.  

Transport aircraft generally don't start to accelerate to retract flaps at least until reaching 1000 ft agl, to keep the initial climb segment as steep as possible. Some noise abatement procedures for airliners require keeping takeoff flap deployed beyond the normal retraction schedule, typically to 3000 feet instead of 1000 feet.  This is to keep the climb as steep as possible to a higher altitude so as not to upset unusually sensitive neighbours farther away from the airport.

That sort of thing is a luxury that jets enjoy because of the massive power reserves. Not so much in a piston twin, which has very little performance reserve when single engine and loaded.  Where an AFM says to do so, you would want to avoid climbing with takeoff flap any more than you have to for obstacle clearance, since if an engine quits, the airplane's climb gradient becomes more of a descent gradient until flaps and gear are retracted, and even then what climb you get is pretty stately - and only if your speed and technique is spot on.

So I don't think the seemingly contradictory conditions you gave are inconsistent in that context.