Sounds wrong to me, and I would say, "I turned the computer off, and then on again", but I was wondering if both forms are acceptable.
FumbleFingers' comment points to what's going on here:
... you can't turn on and off a computer, whereas you can step on and off the scales (or walk up and down the road, etc., etc.)
In step on and off the scales both on and off act as prepositions, taking scales as their respective objects, and conjoining the two prepositions implies an ellipsis of two conjoined preposition phrases: on the scales and off the scales. This is consonant with how we express the result of each action:
I step on the scales. > I am now on the scales.
I step off the scales. > I am now off the scales.
But in turned on (or off) the computer*, on (or off) does not act as a preposition but as an adjective designating a state which you cause the computer to assume. Note that with turn, unlike with step, on (or off) can be posed after the object:
I turned on the computer = I turned the computer on > The computer is now on.
The preposition phrases implicit in the conjunct preposed prepositions are not valid. Consequently we must postpose the conjunction:
I turned the computer on and off.
This question and the answers it received constitute a very interesting case because OP wanted to know whether
"I turned on and off the computer"
is grammatically correct?,
when in fact all the answers have tried to explain why it is not preferable, while apparently forgetting to make it clear whether it is really "grammatically wrong" or just an awkward construction.
Looking at the sentence I see a subject-verb-object sequence as in
I (subject) turned on and off (verb + adverbs) the computer (object.)
Meaning: I turned on and turned off the computer.
I agree that it's not ideally structured -- the better construction would be
I turned the computer on and off
(repeatedly doing which, by the way, is not recommended by either software or hardware engineers) -- but I see nothing to indicate it is grammatically wrong; it only seems awkward: other examples are
he continuously pressed in and out the master switch.
they kept pushing up and down the stairs the rubber sledge.
she called up, greeted and asked again and again the receptionist whether the tickets were ready [deliberately provocative example]
In each case the sentence construction is admittedly awkward, but not necessarily 'grammatically wrong', methinks; expert grammarians can correct me if I am mistaken in this interpretation, and explain why OP's sentence would be "grammatically wrong" while quoting the relevant rule in an answer or comments.
Note 2: can somebody clarify what is the definition/ interpretation (widely accepted by standard resources and grammarians) of the oft-repeated and controversial term "grammatically correct", especially as it applies to this question raised by OP?
I think you're mixing two questions. Turning the computer off and on is something you can only do when it is on to start with. I flicked the light switch on and off (to test the power, because it started in the 'off' position) is a perfectly normal phrase, but does not denote the same process as turning the light off and on (to give the starter a better chance), though that is equally normal.
And whether you insert again in the phrase is largely a matter of choice. It may be that 'flicking the switch on and off' is a single action ending in the off position, where 'flicking it on and off' is more aimless; but equally that may be more precise than most people's language actually is.